3

I am facing problem with the UIImagePickerController in iOS 5.

My App was developed in iOS4.3 but now I am upgrading it to iOS5.

My App crashes when I try to select Image from Photo Library.

It is crashing in main.m file with EXE_BAD_ACCESS and does not giving any crash logs.

I am using following code for UIImagePickerController to pick image from photo library.

-(IBAction) photoLibraryAction {
    if ([self isPad]) {

    UIImagePickerController* picker = [[UIImagePickerController alloc] init]; 
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    picker.delegate = self; 

    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
    self.popoverController = popover; 
    //[popover release];
    [popoverController presentPopoverFromRect:CGRectMake(btnLibraryPic.frame.origin.x, btnLibraryPic.frame.origin.y, btnLibraryPic.frame.size.width, btnLibraryPic.frame.size.height) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];


    //[picker release];
}else {
    ipc=[[UIImagePickerController alloc] init];
    ipc.delegate=self;

    ipc.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentModalViewController:ipc animated:YES];
} 
}


 #pragma mark - Image Picker Delegate
 -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
  {
 [[picker parentViewController] dismissModalViewControllerAnimated:YES];
 [picker release];
  }



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

imgV.image =[info objectForKey:UIImagePickerControllerOriginalImage];

if ([self isPad]) {
    [popoverController dismissPopoverAnimated:YES];
}

[[picker parentViewController] dismissModalViewControllerAnimated:YES];

[picker release];   

 }

I have searched on SO and I found many links like1, like2, like3, like4 and like5.

But none of this contain any proper solution.

What should I do ?

Community
  • 1
  • 1
Devang
  • 11,258
  • 13
  • 62
  • 100

1 Answers1

5
[picker dismissModalViewControllerAnimated:YES];
Devang
  • 11,258
  • 13
  • 62
  • 100