提问人:kanso 提问时间:9/25/2020 更新时间:9/25/2020 访问量:1525
从已呈现的 UIViewController 呈现 UIImagePickerController
Present UIImagePickerController from UIViewController that is already presented
问:
我创建了一个设置/编辑类型的视图控制器,如下所示:
EditViewController *editController = [storyboard instantiateViewControllerWithIdentifier:@"parent"];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:editController];
editController.delegate = self;
navController.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:navController animated:YES completion:nil];
注意:EditViewController 是 UITableViewController 的子类,而“self”只是主导航视图控制器。
现在,从这个呈现的导航控制器/视图控制器中,有一个 UIImageView,用户可以选择通过从相机拍摄照片来填充,他们通过按钮操作来完成:
- (IBAction)takePhotoForImageView:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
picker.modalPresentationStyle = UIModalPresentationFullScreen;
[self showViewController:picker sender:self];
// [self presentViewController:picker animated:YES completion:nil];
}
代码运行而不会崩溃,但我在调试器中得到以下信息:
[Camera] Failed to read exposureBiasesByMode dictionary: Error Domain=NSCocoaErrorDomain
Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data
is NULL" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver
_initForReadingFromData:error:throwLegacyExceptions:]: data is NULL}
[Presentation] Attempt to present <UIImagePickerController: 0x11d00fe00> on
<UINavigationController: 0x11e009c00> (from <EditViewController: 0x11d010c00>)
while a presentation is in progress.
我不知道第一个错误,但假设它与第二个错误有关。
对于第二个错误/警告(?),在显示UIImagePickerController之前关闭第一个显示的控制器不是一个选项。
所以问题是:从另一个视图控制器中启动 UIImagePickerController(源类型为 UIImagePickerControllerSourceTypeCamera)的正确方法是什么?
答: 暂无答案
评论
exposureBiasesByMode