考虑这个视图控制器层次结构:
UIViewController (root)
- present: UINavigationController
- push: UIViewController A
- push: UIViewController B
- present: UIImagePickerController
当解雇UIImagePickerController时,UINavigationController会弹出它的根视图控制器(A)。
以下是要呈现的代码:
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationFullScreen;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.mediaTypes = @[ (NSString *)kUTTypeImage ];
imagePickerController.delegate = self;
[self presentViewController: imagePickerController
animated: YES
completion: nil];
我尝试了各种方案和目标,以便为视图控制器提供相同的最终结果。在UIImagePickerController关闭之前/之后保存/恢复viewController堆栈会导致不合需要的视图转换。
有没有办法实现这个目标?
答案 0 :(得分:0)
只要您使用UIModalPresentationOverFullScreen modalPresentationStyle,解雇就会起作用。
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationOverFullScreen;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.mediaTypes = @[ (NSString *)kUTTypeImage ];
imagePickerController.delegate = self;
[self presentViewController: imagePickerController
animated: YES
completion: nil];