Mobile 设置不同动作的摄像头按钮swift 3

Mobile 设置不同动作的摄像头按钮swift 3,mobile,swift3,Mobile,Swift3,我正在创建一个应用程序,首先打开相机。我能做到。用户拍照后,会显示两个选项,“使用照片”或“取消”。我的问题是,我如何在swift 3中编写代码,将“使用照片”按钮设置为我的便利,例如将照片存储到图库或其他一些操作。请建议一些代码来实现这一点。谢谢 以下是我打开相机时使用的代码: class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelega

我正在创建一个应用程序,首先打开相机。我能做到。用户拍照后,会显示两个选项,“使用照片”或“取消”。我的问题是,我如何在swift 3中编写代码,将“使用照片”按钮设置为我的便利,例如将照片存储到图库或其他一些操作。请建议一些代码来实现这一点。谢谢

以下是我打开相机时使用的代码:

class ViewController: UIViewController, UINavigationControllerDelegate,         UIImagePickerControllerDelegate {
        override func viewDidAppear(_ animated: Bool) {
            if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
                let image = UIImagePickerController() 
                image.delegate = self  
                image.sourceType = UIImagePickerControllerSourceType.camera   
                image.allowsEditing = false
                self.present(image, animated: true)
            } else {
                print("This device does not support camera")
            }
        }
   }


  func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {  
    if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
        myImageView.image = image
    }
    else {
        //Error message
    }
    self.dismiss(animated: true, completion: nil)
    print("camera is dismissed or not")
}
我的问题是,我如何在swift 3中编写代码,将“使用照片”按钮设置为我的便利,例如将照片存储到图库或其他一些操作


您已经将
ViewController
设置为图像拾取控制器的代理,因此您只需在
ViewController
中实现该方法,我实现了该方法,但我的相机不会在单击“使用照片”按钮时关闭,即使我已取消该按钮。我已经用新代码更新了我的帖子。