0

Can you give some examples for UIImage Picker controller..

let title = "Take a new photo or select one from your library"
    let alertController = UIAlertController(title: title, message: "", preferredStyle: .alert )


    // Create the action.
    let Camera = UIAlertAction(title: "CAMERA", style: .default,  handler:  {
        action in
            if UIImagePickerController .isSourceTypeAvailable(UIImagePickerControllerSourceType .camera)
            {
                self.present(self.picker, animated: true, completion: nil)
            }

    })

    let Gallery = UIAlertAction(title: "GALLERY", style: .default,  handler: {
        action in
        alertController.dismiss(animated: true, completion: {
            if UIImagePickerController .isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary)
            {
                self.present(self.picker, animated: true, completion: nil)
            }
        })
    })

    alertController.addAction(Gallery)
    alertController.addAction(Camera)

    // Show alert
    present(picker, animated: true, completion: nil)
Anbu.Karthik
  • 80,161
  • 21
  • 166
  • 138
Amutha Kumari
  • 113
  • 1
  • 3
  • 11

0 Answers0