ios - 从已经呈现的 UIViewController 呈现 UIImagePickerController
问题描述
我创建了一个设置/编辑类型的视图控制器,如下所示:
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)的正确方法是什么?
解决方案
推荐阅读
- c# - 如何在 vscode C# IntelliSense 中排除文件夹?
- python - 如何将几个附加参数传递给作为 LowLevelCallable 传递给 scipy.integrate.quad 的 numba cfunc
- xamarin.forms - 无法让 Firebase 为 Xamarin Forms iOS 工作
- wordpress - 在 WooCommerce 商店和档案页面上为可变产品发布隐藏产品单一价格
- c++ - 我已经使用堆栈(stl)来找到两个链表的交点,但是我遇到了分段错误,下面是我的函数,
- android - 在 Android Studio 中检测传输文件和传输照片(USB MASS Storage)的 Intent 过滤器
- reactjs - 在使用 reactjs 构建的任何网站上使用 chrome 扩展自动填充密码
- api - 通过 API V1 更新意图对话框流程
- javascript - 鼠标与触摸:使用 javascript 可靠地检测实际用户输入,而不是设备功能
- reactjs - 如何在休假时清除表单数据 - 反应原生