2013-03-14 77 views
1

我正在开发一个应用程序,我需要保持打开全屏相机打开并在其上添加一个按钮(右下角)。我google搜索,但无法找到任何健康的解决方案。提前致谢。祝你有美好的一天。 编辑如何在Xcode中打开全屏相机

- (void) showCameraUI { 
    [self startCameraControllerFromViewController: self 
            usingDelegate: self]; 
} 

- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller 
            usingDelegate: (id <UIImagePickerControllerDelegate, 
                UINavigationControllerDelegate>) delegate { 


    if (([UIImagePickerController isSourceTypeAvailable: 
      UIImagePickerControllerSourceTypeCamera] == NO) 
     || (delegate == nil) 
     || (controller == nil)) 
     return NO; 

    NSLog(@"Start Camera Controller method..."); 
    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; 
    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera; 

    // Displays a control that allows the user to choose picture or 
    // movie capture, if both are available: 
    cameraUI.mediaTypes = 
    [UIImagePickerController availableMediaTypesForSourceType: 
    UIImagePickerControllerSourceTypeCamera]; 

    // Hides the controls for moving & scaling pictures, or for 
    // trimming movies. To instead show the controls, use YES. 
    cameraUI.allowsEditing = NO; 

    cameraUI.delegate = delegate; 

    [controller presentModalViewController: cameraUI animated: YES]; 
    return YES; 
} 

P.S:我还添加了UINavigationControllerDelegate,UIImagePickerControllerDelegate在头文件协议,但它仍然没有打开相机,让我看看默认视图项目。

+0

你想要的相机总是作为一个全屏幕的我的朋友开放。使用ImagePickercontroller。 – 2013-03-14 06:14:56

+0

我试图一直以全屏模式打开相机。看到我编辑的帖子 – josh 2013-03-14 06:29:01

回答

2

你可以简单地捕捉图像使用相机像波纹管,我用我的代码这种波纹管方法: -

-(void)btnCemeraOpen 
{ 
     UIImagePickerController * picker = [[UIImagePickerController alloc] init]; 
     picker.delegate = self; 


     if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
     {  
       picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
       [self presentModalViewController:picker animated:YES]; 
     } 
} 

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
    [self dismissModalViewControllerAnimated:YES]; 
    yourImageView.image = [info valueForKey:@"UIImagePickerControllerOriginalImage"]; 
    if(yourImageView==nil) 
    { 

    } 
    else 
    { 
     //DO logic 

    } 

    return; 
}