我可以为图像选择器调用模态视图控制器,选择图像并裁剪它,但是当我点击“完成”它没有做任何事情时,它只是挂起,完成按钮变灰。 没有错误,但调用该函数。
- (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];
}
答案 0 :(得分:2)
替换
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
使用:
[self dismissModalViewControllerAnimated:YES];