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;
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]]; }
source share