我在iOS 5中遇到了
我的应用程序是在
当我尝试从照片库中选择图像时,我的应用程序会崩溃。
它在main.m文件中崩溃,并显示
我使用以下代码从照片库中选取图片:
我在SO上搜索了很多链接,如like1、like2、like3、like4和like5。但是这些都没有提供任何适当的解决方案。
我该怎么办?
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上搜索了很多链接,如like1、like2、like3、like4和like5。但是这些都没有提供任何适当的解决方案。
我该怎么办?
release
调用被注释掉了。 - Michael Dautermann[[picker parentViewController] dismissModalViewControllerAnimated:YES];
更改为[picker dismissModalViewControllerAnimated:YES];
。 - chris