iOS 5:UIImagePickerController崩溃

3
我在iOS 5中遇到了UIImagePickerController的问题。
我的应用程序是在iOS4.3上开发的,现在我正在升级到iOS5
当我尝试从照片库中选择图像时,我的应用程序会崩溃。
它在main.m文件中崩溃,并显示EXE_BAD_ACCESS,但没有提供任何崩溃日志。
我使用以下代码从照片库中选取图片: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上搜索了很多链接,如like1like2like3like4like5。但是这些都没有提供任何适当的解决方案。
我该怎么办?

1
也许可以先描述一下问题。出了什么错?有崩溃日志吗? - PengOne
你现在使用ARC了吗?我注意到你的一些release调用被注释掉了。 - Michael Dautermann
我已经尝试过删除[picker release],但它仍然崩溃。 - Devang
它在iPhone或iPad上崩溃了吗?两个都是吗? - zpasternack
2
尝试将[[picker parentViewController] dismissModalViewControllerAnimated:YES];更改为[picker dismissModalViewControllerAnimated:YES]; - chris
显示剩余6条评论
1个回答

5
[picker dismissModalViewControllerAnimated:YES];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接