iOS 5 : UIImagePickerController crash

邮差的信 提交于 2019-12-10 21:50:07

问题


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 ?


回答1:


[picker dismissModalViewControllerAnimated:YES];


来源:https://stackoverflow.com/questions/8454820/ios-5-uiimagepickercontroller-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!