PDA

View Full Version : Creating a single function that display fullscreen camera.




Bracer
Dec 14, 2009, 05:22 AM
I am trying to create a single function that will call up the camera to fullscreen.

This code hang the program :(

-(void)setCameraFullScreen
{

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_SCALAR, CAMERA_SCALAR);
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES]; //Show the Picker
[picker release];
}


Can anyone help in accessing the problem with this code ?



miep
Dec 14, 2009, 08:01 AM
move the [release picker] statement to the dealloc of the class?

Don't know about presentModalViewController, but if it returns immediately, releasing the picker at that spot (which you've set as the delegate) sort of pulls the rug out from under its feet.

ghayenga
Dec 14, 2009, 12:02 PM
move the [release picker] statement to the dealloc of the class?

Don't know about presentModalViewController, but if it returns immediately, releasing the picker at that spot (which you've set as the delegate) sort of pulls the rug out from under its feet.

No, that's the standard method. The viewController hierarchy maintains it's own reference to it so if you don't release it you'll probably end up leaking pickers, because the a) the parent object may not get released until the app closes and b) you may call up the camera picker multiple times while the app is open.

Bracer
Dec 15, 2009, 12:48 AM
I have find out how it's done and I am going to create a separate thread to share it with the community.