关闭相机后。它给了我这个警告:在演示过程中尝试继续演示!
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
我不知道这是不是个大问题。
更多代码:
- (void) viewWillAppear:(BOOL)animated
{
[self takePicture];
}
- (void) takePicture
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
} else
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissViewControllerAnimated:NO completion:nil];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:NO completion:nil];
}
顺便说一句,“dismissModalViewController”已被弃用。
修复: 一旦有新 View ,将调用 ViewWillAppear。这就是问题所在
最佳答案
您不应该从 viewWillAppear 中呈现任何 Controller ,因为当前 View Controller 的呈现尚未完成。
从 viewDidAppear 调用 takePicture 因为 viewDidAppear 将在 Controller 呈现完成后被调用。
- (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; [self takePicture]; }
希望对您有所帮助。
关于ios - 警告 : Attempt to present uiimagepickercontroller while a presentation is in progress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19255200/