关闭相机后。它给了我这个警告:在演示文稿正在进行时尝试演示!
- (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”已被弃用。
修正: 一旦有新视图,将调用ViewWillAppear。这就是问题
答案 0 :(得分:8)
您不应该从viewWillAppear呈现任何控制器,因为当前视图控制器的呈现尚未完成。
从viewDidAppear调用takePicture,因为一旦控制器的显示完成,将调用viewDidAppear。
- (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; [self takePicture]; }
希望这会对你有所帮助。
答案 1 :(得分:0)
您可能已经提供了一些像这样的视图控制器
[self presentViewController:someVC animated:YES completion:nil];
在动画完成之前,您的下面方法称为
imagePickerControllerDidCancel
您可以将其更改为
进行检查[self presentViewController:someVC animated:NO completion:nil];
注意动画:上面没有。