捕获图像后,会发生回调,但出现错误,因为它不会解除相机视图。我的代码非常直接,我唯一的疑问是我使用标签栏控制器并在其中一个标签中推送imagePicker,只是一个想法。
- (IBAction)imageButtonPressed:(id)sender {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
[self presentModalViewController:imagePicker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissModalViewControllerAnimated:YES];
self.portaitImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
}
答案 0 :(得分:2)
你需要解雇UIImagePickerController,而不是self
:
[picker dismissModalViewControllerAnimated:YES];