This is my code:
-(IBAction)addUserChooseImage:(id)sender{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage: (UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
uploadedImage.image = image;
[picker dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissModalViewControllerAnimated:YES];
}
It sticks when trying to dismiss the picker. I believe the reason is that the image picker is activated by a button that sits on a loaded nib view over the viewcontroller itself.
Can anyone tell me what is the right way to dismiss it? I guess the delegate should still refer to self, right?
Thanks
You can’t dismiss picker using the
[picker dismissModalViewControllerAnimated:YES];method.Replace
[picker dismissModalViewControllerAnimated:YES];with[self dismissModalViewControllerAnimated:YES];