我正在尝试使用以下代码在 UINavigationController
中呈现一个 UIImagePickerController
:
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.showsCameraControls = NO;
imagePicker.modalPresentationStyle = UIModalPresentationOverCurrentContext;
self.tabBarController.tabBar.hidden = YES;
NSLog(@"HERES THE self.peresntingviewcontorller:: %@", self.presentingViewController);
//[self presentViewController:imagePicker animated:YES completion:^{}];
UINavigationController *cameraNavigationController = [[UINavigationController alloc] initWithRootViewController:imagePicker]; //ERROR HERE
[self presentViewController:cameraNavigationController animated:YES completion:nil];
但是我在添加注释“//ERROR HERE”时遇到错误,这是我尝试启动导航 Controller 的行,其中包含名为 的 UIImagePickerController
的 Root View 图片选择器。我不知道我做错了什么?有帮助吗?
错误是:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
最佳答案
UIImagePickerController 派生自 UINavigationController,这就是为什么你不能将它推送到另一个 UINavigationController(或设置为 Root View Controller )。
关于ios - NavigationController initWithRootViewController 崩溃应用程序 iOS8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31572131/