0

我正在使用 presentViewController:imagePickerController 来显示 UIImagePickerController。由于某种原因,当我最终解散该控制器时,我的原始导航控制器失去了它的堆栈,我的应用程序又回到了根视图控制器。

我正在记录 self.navigationController.viewControllers 并且我可以看到,在我运行 presentViewController:imagePickerController 行之后,我的导航控制器失去了除根控制器之外的所有控制器。

 UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
 imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
 imagePickerController.sourceType = sourceType;
 imagePickerController.delegate = self;
 imagePickerController.navigationBarHidden = YES;

 self.imagePickerController = imagePickerController;

DLog(@"self.navigationController:%@",self.navigationController.viewControllers);
[self.navigationController presentViewController:imagePickerController animated:YES completion:^{
        DLog(@" after presenting self.navigationController:%@",self.navigationController.viewControllers);

    }];

////关闭它

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    DLog(@"self.navigationController:%@",self.navigationController.viewControllers);
    [self.navigationController dismissViewControllerAnimated:YES completion:^{

    }];
}

/////我的NC设置在哪里

OFMainViewController *mainController = [[OFMainViewController alloc]init];
    mainController.managedObjectContext = self.managedObjectContext;
    navigationController = [[UINavigationController alloc]initWithRootViewController:mainController];
[self.window setRootViewController:navigationController];
4

2 回答 2

1

而不是使用 self.navigationController 使用 self 来关闭和调用 imagepickerviewcontroller。

于 2013-08-20T13:22:23.237 回答
0

您应该在imagePickeControlleronself而不是self.navigationController.

[self presentViewController:imagePickerController animated:YES completion:^{
    DLog(@" after presenting self:%@",self.navigationController.viewControllers);

}];

并相应地驳回它:

////Closing it

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    DLog(@"self.navigationController:%@",self.navigationController.viewControllers);
    [self dismissViewControllerAnimated:YES completion:^{

    }];
}
于 2013-08-20T13:26:46.053 回答