iOS 5:UIImagePickerController崩溃

时间:2011-12-10 06:13:37

标签: iphone ios4 ios5 uiimagepickercontroller

我在iOS 5中遇到UIImagePickerController的问题。

我的应用程序是在iOS4.3中开发的,但现在我将其升级到iOS5

当我尝试从照片库中选择图像时,我的应用程序崩溃。

它在带有EXE_BAD_ACCESS的main.m文件中崩溃,并且没有提供任何崩溃日志。

我正在使用UIImagePickerController的以下代码从照片库中选择图片。

-(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];   

 }

我搜索了SO,发现了许多链接like1like2like3like4  和like5

但这些都没有任何适当的解决方案。

我该怎么办?

1 个答案:

答案 0 :(得分:5)

[picker dismissModalViewControllerAnimated:YES];