UIImagePicker - Do not allow panorama to be picked

1k views Asked by At

Looking for help with an image picker. The picker is functioning properly - however - it allows the user to pick from Panorama photos as well as normal photos on their device.

I want to have the picker only allow the user to choose non panorama pictures.

I looked through the dev document and couldn't find anything about this. Any help appreciated! Here's my code:

 @IBAction func selectImage(sender: AnyObject) {
    let imagePicker = UIImagePickerController()
    imagePicker.delegate = self
    imagePicker.sourceType =
        UIImagePickerControllerSourceType.PhotoLibrary
    imagePicker.mediaTypes = [kUTTypeImage as NSString]
    imagePicker.allowsEditing = false
    self.clearBtn.hidden = false
    self.presentViewController(imagePicker, animated: true,
        completion: nil)

}

func imagePickerController(picker: UIImagePickerController,
    didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
        self.dismissViewControllerAnimated(true, completion: nil)
        let image = info[UIImagePickerControllerOriginalImage] as! UIImage
        self.postImage.contentMode = .ScaleAspectFit
        self.postImage.image = image
        self.hasPicture = true
}

I know that changing the UIImagePickerControllerSourceType to .PhotoLibrary will only allow picking from the camera roll, but I was hoping to still allow shared photo streams and such that just weren't panoramic.

1

There are 1 answers

0
Charlie On BEST ANSWER

As Christian posted in a comment - there is no native way for a UIImagePicker to only allow certain types of pictures (excluding panorama).

You have to handle validating the image after it is returned.