2011-12-10 117 views
3

我現在面臨的問題與UIImagePickerController在IOS 5的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

+0

你現在在使用ARC嗎?我注意到你的'release'調用中的一些*被註釋掉了。 –

+0

@PengOne:我沒有收到任何崩潰日誌,它在main.h中顯示「EXE_BAD_EXCESS」。我的代碼適用於iOS4.3。 – Devang

回答

5
[picker dismissModalViewControllerAnimated:YES];