如何在swift中的UIImagepickercontroller中选择多个图像

时间:2017-05-30 05:24:46

标签: ios swift ios8 uiimageview uiimagepickercontroller

您能为UIImage Picker控制器提供一些示例..

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)

0 个答案:

没有答案