【发布时间】:2015-07-22 19:18:03
【问题描述】:
我正在尝试使用以下代码在 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”时遇到错误,我尝试在该行中使用名为 imagePicker 的 UIImagePickerController 的根视图启动导航控制器.我不知道我做错了什么?有什么帮助吗?
错误是:
由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因:'推导航控制器 不支持'
【问题讨论】:
-
这段代码在哪里运行,
self的类型是什么? -
我刚刚发现显示 imagePicker 的视图控制器已经在 UINavigationController 中,因此我无法在顶部显示新的 navController.. >Apple 不允许堆叠导航控制器
-
你在用模拟器吗?
UIImagePickerControllerSourceTypeCamera仅在 iOS 设备中的模拟器中不受支持。对于模拟器,您可以使用UIImagePickerControllerSourceTypePhotoLibrary进行测试
标签: ios uinavigationcontroller