Camera freezes if FinishPickingMediaWithInfo is defined

I am trying to do basic shooting with an iPhone. I used the following code to show the camera:

- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller usingDelegate: (id <UIImagePickerControllerDelegate, UINavigationControllerDelegate>) delegate { if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil)) return NO; UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera; // Displays a control that allows the user to choose picture or // movie capture, if both are available: cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeCamera]; // Hides the controls for moving & scaling pictures, or for // trimming movies. To instead show the controls, use YES. cameraUI.allowsEditing = NO; cameraUI.delegate = delegate; [controller presentModalViewController: cameraUI animated: YES]; return YES; } 

This works fine, but if I define a processing function:

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { } 

The imagePicker control freezes after clicking the "Use" button. This is not a failure, does not cause any exception, the code does something, but on the screen I see only the frozen imagePicker control. Even if the handler is empty, the control freezes. If I delete the handler, the camera usually disappears and displays the view from which the camera was activated ... Am I missing something important here?

UPDATE: I tried to assign a UIImageView image, the code executes, exits the function and that it, the camera remains on the screen:

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [[picker parentViewController] dismissModalViewControllerAnimated:YES]; UIImage* original =[info objectForKey:@"UIImagePickerControllerOriginalImage"]; [[self imgWLItemImage] setImage:[UIImage imageWithCGImage:original.CGImage scale:0.25 orientation:original.imageOrientation]]; } 
+4
source share
1 answer

Try this and check:

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; UIImage* original =[info objectForKey:@"UIImagePickerControllerOriginalImage"]; [[self imgWLItemImage] setImage:[UIImage imageWithCGImage:original.CGImage scale:0.25 orientation:original.imageOrientation]]; } 
+12
source

All Articles