UIImagePicker 冻结

问题描述:

我可以调用图像选择器的模态视图控制器,选择图像并裁剪它,但是当我点击完成"时它什么也不做,它只是挂起,完成按钮变灰.没有错误,但调用了该函数.

I'm able to call the modal view controller for the image picker, pick the image, and crop it, but when I tap 'done' it doesn't do anything, it just hangs with the done button grayed out. There are no errors, but the function is called.

- (void)viewDidLoad
{
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
userImage.image = img;
uploadButton.hidden = NO;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
NSLog(@"called");
}

- (IBAction)getImage:(id)sender {
[self presentModalViewController:self.imgPicker animated:YES];
}

替换

 [[picker parentViewController] dismissModalViewControllerAnimated:YES];

与:

 [self dismissModalViewControllerAnimated:YES];