2015-10-16 42 views
-1

我模態推到了一個新的視圖控制器使用:現在UIImagePicker

[self presentViewController:picker]; 

,然後從我做了新的視圖控制器內;

UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
    picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
picker.delegate = self; 
    [self presentViewController:picker animated:YES completion:nil]; 

但是相機甚至不會顯示,爲什麼?

回答

0

我有同樣的問題在iPad和下面的代碼爲我工作...

[[NSOperationQueue mainQueue] addOperationWithBlock:^{ 
    //present your view controller here... 
}]; 

GOOD LUCK !! :)

0

這可能是由於兩個原因:

1)創建的攝像機開孔代碼的方法:

-(void) openCamera { 
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
picker.delegate = self; 
[self presentViewController:picker animated:YES completion:nil]; } 

何地,你想這樣稱呼它,

[self performSelector:@selector(openCamera) withObject:nil afterDelay:0.1]; 

2)在此方法內寫代碼,

[[NSOperationQueue mainQueue] addOperationWithBlock:^{ 

    //... Camera Code .... 

}];