需要按两次取消按钮才能转到上一个视图控制器



当我在我的应用程序中使用相机时,我想检查用户是否单击了取消按钮,但是当我使用此代码时,我需要按取消按钮 2 次才能运行_ = navigationController?.popViewController(animated: true)但是当我尝试将其替换为print("hello")它有效时,我只需要按一次取消按钮。 我该怎么做才能解决此问题?

func imagePickerControllerDidCancel(_ picker: UIImagePickerController){
_ = navigationController?.popViewController(animated: true)
}

因为您还需要隐藏选取器

func imagePickerControllerDidCancel(_ picker: UIImagePickerController){
picker.dismiss(animated: true) {
self.navigationController?.popViewController(animated: true)
}
}

最新更新