在popover中解除UIImagePickerController

时间:2018-03-18 13:58:28

标签: ios swift uiimagepickercontroller popover dismiss

我有以下视图层次结构: 视图控制器A - > popover segue - >导航控制器 - >视图控制器B - >的UIImagePickerController

在View控制器B popover中,我使用以下代码来呈现UIImagePickerController:

picker = UIImagePickerController()
picker!.allowsEditing = false
picker!.sourceType = .photoLibrary
picker!.mediaTypes = [kUTTypeMovie as String]
picker!.isModalInPopover = true
picker!.modalPresentationStyle = .currentContext
picker!.delegate = self
present(photoLibraryPickerController!, animated: true, completion: nil)

当用户点击“取消”时,我想解雇图像选择器和视图控制器B弹出窗口,然后直接返回查看控制器A.这是我的代码:

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
    picker!.dismiss(animated: false, completion: nil)
    dismiss(animated: false, completion: nil)
}

这有效地消除了图像选择器和视图控制器B,但是在图像选择器被解除之后存在短暂的延迟。因此,您可以在屏幕上看到视图控制器B片刻,然后再将其解除。

如何同时关闭两个视图控制器以避免闪烁?

0 个答案:

没有答案