我使用以下方式将模态推送到新的视图控制器:
[self presentViewController:picker];
然后从我所做的那个新视图控制器中开始;
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
[self presentViewController:picker animated:YES completion:nil];
但相机甚至不会显示,为什么?
答案 0 :(得分:0)
我在iPad上遇到了同样的问题,下面的代码对我有用......
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
//present your view controller here...
}];
祝你好运! :)
答案 1 :(得分:0)
这可能是由于以下几个原因造成的:
1)创建一个Camera Opening代码的方法:
-(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];
OR
2)在此方法中编写代码,
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
//... Camera Code ....
}];