Reputation: 149
I develop an app that take a picture from camera unitl here all well bat after receive from his delegate i dismiss and i receive exc_bad_access here is the code:
declare and open the camera:
-(void)ScattaFoto{
UIImagePickerController *picke = [[UIImagePickerController alloc] init];
// Delegate is self
picke.delegate = self;
// Allow editing of image ?
picke.allowsEditing=NO;
if(TARGET_IPHONE_SIMULATOR) {
picke.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}else{
picke.sourceType = UIImagePickerControllerSourceTypeCamera;
}
// Show image picker
[self presentModalViewController:picke animated:YES];
}
and than is the delegate event:
- (void) imagePickerController:(UIImagePickerController *)picke didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
//UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
// [picker release];
[self dismissModalViewControllerAnimated: YES]; // Here i receive exc_bad_access
[picke release];
}
i put on .h the refer to delegate of imagePickerControl "UINavigationControllerDelegate, UIImagePickerControllerDelegate"
Someone can help me?
Upvotes: 2
Views: 3908
Reputation: 89
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{
[picker.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
Upvotes: 1
Reputation: 101
Maybe ARC is releasing your UIImagePickerController before didFinishPickingMediaWithInfo is called?
Try placing your UIImagePickerController in a @property like this:
@property (nonatomic, strong) UIImagePickerController *picke;
You can read more about @properties here.
You will still have to allocate and initialize the UIImagePickerController before you use it.
Upvotes: 0
Reputation: 29767
- (void) imagePickerController:(UIImagePickerController *)picke didFinishPickingMediaWithInfo:(NSDictionary *)info{
[picke dismissModalViewControllerAnimated: YES];
}
Upvotes: 3