我正在使用 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];