I am presenting a table view controller after taking a picture with this code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// NSLog(@"didFinishPickingMediaWithInfo");
[self.tabBarController dismissViewControllerAnimated:NO completion:nil];
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
NSLog(@"A photo was taken!");
CCCameraViewController *viewController = [[CCCameraViewController alloc] initWithImage:self.image];
[viewController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.navController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.navController pushViewController:viewController animated:YES];
self.navController.navigationBar.tintColor = [UIColor blueColor];
viewController.tableView.tintColor = [[UIColor alloc] initWithRed:49.0 / .0 green:.0 / .0 blue:.0 / .0 alpha:1.0];
[self.tabBarController presentViewController:self.viewController animated:YES completion:nil];
But when I run and after I take the picture and try to present CCcameraviewController
, i get this termination error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target .'
Should be
[self.tabBarController presentViewController:self.navController animated:YES completion:nil];
It's self.navController
not self.viewController
you should set self.viewController
first. Like this :
CCCameraViewController *viewController = [[CCCameraViewController alloc] initWithImage:self.image];
self.viewController = viewController;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.