开发者

how to close imagePickerController?

开发者 https://www.devze.com 2023-01-26 02:40 出处:网络
I just can\'t get this: how in the world can I \"shut down\" imagePickerController on xcode? This is the code that opens the camera, and it works perfectly..

I just can't get this:

how in the world can I "shut down" imagePickerController on xcode? This is the code that opens the camera, and it works perfectly..

-(IBAction) startcamera {


imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePickerController.allowsEditing = NO;
imagePickerController.showsCameraControls=NO;
imagePickerController.toolbarHidden=YES ;
imageP开发者_运维技巧ickerController.wantsFullScreenLayout=YES;
imagePickerController.cameraOverlayView=self.view;
self.imagePickerController.delegate=self;
    [self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];

}

Ok now, say I want to close imagePickerController by clicking a button (means without picking any image): how am I supposed to do that? Tried with:

-(IBAction)closecamera {


[imagePickerController release];
    [imagePickerController dismissModalViewControllerAnimated:YES];

}

but it doesn't work! Any clues? Thanks in advance


  1. Don't release imagePickerController twice.
  2. You would dismiss it with [self dismissModalViewControllerAnimated:YES];


Don't release it twice and dismiss it before you release it. (like ole said)

But this is also important... as soon as you have released an object it is gone and no methods can be called.

0

精彩评论

暂无评论...
验证码 换一张
取 消