Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 需要按两次“取消”按钮才能转到上一个视图控制器_Swift - Fatal编程技术网

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

Swift 需要按两次“取消”按钮才能转到上一个视图控制器,swift,Swift,当我在我的应用程序中使用摄像头时,我想检查用户是否单击了取消按钮,但当我使用此代码时,我需要按两次取消按钮,然后它才会运行\uuu=navigationController?.popViewController(动画:true),但当我尝试用打印(“hello”)替换它时它可以工作,我只需按一下“取消”按钮。我可以用什么方法解决此问题 func imagePickerControllerDidCancel(_ picker: UIImagePickerController){ _ = n

当我在我的应用程序中使用摄像头时,我想检查用户是否单击了取消按钮,但当我使用此代码时,我需要按两次取消按钮,然后它才会运行
\uuu=navigationController?.popViewController(动画:true)
,但当我尝试用
打印(“hello”)替换它时
它可以工作,我只需按一下“取消”按钮。我可以用什么方法解决此问题

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

因为你还需要隐藏选择器

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

如果不分配输出,会发生什么情况?只需执行navigationController?.popViewController(动画:true)并告诉我们这是否有不同。@Milander我刚刚尝试过,我需要按3次取消按钮。什乌·汗给出的答案很有用。看来我得先把拾荒者藏起来,这似乎合乎逻辑。很抱歉,我的回答不起作用,但我很高兴Shu Khan找到了解决办法:)@Milander很好,非常感谢您的帮助