【问题标题】:iOS 5 : UIImagePickerController crashiOS 5:UIImagePickerController 崩溃
【发布时间】:2012-01-17 07:06:30
【问题描述】:

我在 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 上进行了搜索,发现很多链接 like1like2like3like4like5

但这些都不包含任何适当的解决方案。

我该怎么办?

【问题讨论】:

  • 也许从描述问题开始。出了什么问题?什么是崩溃日志?
  • 您现在使用 ARC 吗?我注意到 一些 您的 release 调用被注释掉了。
  • @PengOne:我没有收到任何崩溃日志,它在 main.h 中显示“EXE_BAD_EXCESS”。我的代码适用于 iOS4.3。
  • @MichaelDautermann :不,我没有使用 ARC。
  • 尝试将[[picker parentViewController] dismissModalViewControllerAnimated:YES]; 更改为[picker dismissModalViewControllerAnimated:YES];

标签: iphone ios4 ios5 uiimagepickercontroller


【解决方案1】:
[picker dismissModalViewControllerAnimated:YES];

【讨论】:

    猜你喜欢
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-19
    • 2013-09-27
    • 2015-01-06
    • 2011-12-25
    • 1970-01-01
    相关资源
    最近更新 更多