yjcpu
yjcpu

Reputation: 21

UIImagePickerController can not select picture

I have some problem when i work with UIImagePickerController .when I presentModalViewController,and the picker pops up right,but i can not select a picture! when i touch on the picture list, the list can only scroll up and down,but can not select!

how about this? thanks.

Upvotes: 2

Views: 2542

Answers (3)

Samo
Samo

Reputation: 2181

Swift 4.

I had the same problem, and was able to fix it by adding a

dismiss(animated: true, completion: nil)

at the end of imagePickerController(_:didFinishPickingMediaWithInfo:)

Example:

extension MyViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
            // Do something with your image
            ...
        }
        dismiss(animated: true, completion: nil)
    }
}

Upvotes: 3

Ryan
Ryan

Reputation: 521

the docs provide this answer:

"5. When the user taps a button to pick a newly-captured or saved image or movie, or cancels the operation, dismiss the image picker using your delegate object. For newly-captured media, your delegate can then save it to the Camera Roll on the device. For previously-saved media, your delegate can then use the image data according to the purpose of your app."

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

Upvotes: 1

adam
adam

Reputation: 22577

You must implement the UIImagePickerControllerDelegate method

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

Upvotes: 0

Related Questions