這一個也得到了我之前。如果您在iPad上指定源類型UIImagePickerControllerSourceTypePhotoLibrary
或UIImagePickerControllerSourceTypeSavedPhotoAlbum
,則需要使用彈出式控制器來呈現圖像選取器控制器。如果您嘗試以模態方式呈現它,就像您正在做的那樣,您會得到一個異常。
不是100%必需的,但使用測試來查看可用的源類型也是一個好主意。
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]
源類型:
UIImagePickerControllerSourceTypePhotoLibrary
UIImagePickerControllerSourceTypeSavedPhotosAlbum
UIImagePickerControllerSourceTypeCamera
這是我如何解決這個問題,以測試它是否是一個iPad與否。
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
UIPopoverController* popOverController = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
[popOverController presentPopoverFromRect:selectVideoToViewButton.bounds inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}else {
[self presentModalViewController:self.imagePickerController animated:YES];
}
是的,在文檔概要的音符步驟4 - > http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html – borrrden 2012-08-03 01:03:15