ios - NavigationController initWithRootViewController 崩溃应用程序 iOS8

标签 ios uinavigationcontroller

我正在尝试使用以下代码在 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/

相关文章:

ios - 右侧栏按钮项目的奇怪偏移

ios - 作为 subview Controller 嵌入时 UINavigationController 高度为零

ios - 核心数据 : How to get a notification when document is saved?

ios - 获取保存在 iPhone/iPad 相机胶卷上的所有 GIF 图片

ios - swift - UINavigationController 扩展不工作

iphone - 弹出 Controller 时 UINavigationController 内存不会减少

ios - iPhone 获取所有没有私有(private)库的 SSID 列表

ios - 将 Swift 中的 (Any hashable Any) 中的错误转换为 Objective C 中的 NSMutableDictionary

ios - NSArray 中的 EXC_BAD_ACCES

iphone - 导航栏 "back"关闭模态视图的按钮