Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

iphone - UIImagePickerController didFinishPickingMediaWithInfo not being called

I'm having trouble with using a UIImagePickerController. Basically, though the picker is being displayed fine, the UIImagePickerController didFinishPickingMediaWithInfo method is refusing to be called (I've tried NSLogging all the way through, it just doesn't get called). Here's my code (I've defined imgPicker in the header as an UIImagePickerController):

-(IBAction)grabImage {
    self.imgPicker = [[UIImagePickerController alloc] init];
    self.imgPicker.allowsImageEditing = YES;
    self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentModalViewController:self.imgPicker animated:YES];
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    imgview.image = [info objectForKey:UIImagePickerControllerEditedImage];
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
}

Anyone have any idea as to why it isn't being called?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Have you set the delegate property of UIImagePickerController , if not do as below

myImagePickerController.delegate = self;

also confirm with the UIImagePickerControllerDelegate protocol,


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...