所以我在这里尝试做的只是从自定义相机overlayView中打开相机胶卷。我实现了自定义相机overlayView,创建了一个UIImagePickerController,并用我的自定义覆盖替换了默认覆盖。然后我创建了另一个UIImagePickerController实例,将sourceType设置为PhotoLibrary,并在按下overlayView上的按钮时尝试显示它。
按下按钮时显示以下错误消息:
Warning: Attempt to present <UIImagePickerController: 0x14da5440> on <UINavigationController: 0x14e63760> whose view is not in the window hierarchy!
这是我的代码:
- (IBAction)select:(id)sender
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker
animated:YES completion:nil];
}
}
有谁知道这里的问题是什么?
谢谢!
答案 0 :(得分:-5)
当另一个视图控制器忽略如下时,您需要将完成块用于当前的一个视图控制器:
[self dismissViewControllerAnimated:YES completion:^{
[self presentViewController:imagePicker
animated:YES completion:nil];
}];