我正在尝试使用以下代码在UIImagePickerController
中展示UINavigationController
:
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];
但是我收到了一个错误,我添加了评论" //错误在这里",我试图启动导航控制器的行,我的UIImagePickerController
的根视图名为 imagePicker 即可。我不知道我做错了什么?有什么帮助吗?
错误是:
由于未捕获的异常而终止应用 ' NSInvalidArgumentException',原因:'推送导航控制器 不受支持'
答案 0 :(得分:1)
UIImagePickerController派生自UINavigationController,这就是为什么你不能把它推到另一个UINavigationController(或设置为根视图控制器)。
答案 1 :(得分:0)
听起来您正试图将导航控制器推到另一个导航控制器上。你应该做这样的事情:
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.showsCameraControls = NO;
imagePicker.modalPresentationStyle = UIModalPresentationOverCurrentContext;
self.tabBarController.tabBar.hidden = YES;
[self presentViewController:imagePicker animated:YES completion:nil];