2011-04-28 63 views
0

我在开发iPad应用程序时尝试访问照片库时遇到问题。但是,相同的代码适用于iPhone开发。其中产生的错误是:如何访问ipad应用程序的照片库

On iPad, UIImagePickerController must be presented via UIPopoverController 

我使用为iPad开发了下面的代码:

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) 
     { 
      UIImagePickerController * picker = [[UIImagePickerController alloc] init]; 
      picker.delegate = self; 
      picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
      [self presentModalViewController:picker animated:YES]; 
      [picker release]; 
     } 
+0

什么是错误?给我们一些更多的信息可以帮助。 – Devraj 2011-04-28 07:21:44

+0

控制台上显示的错误是: – 2011-04-28 07:25:18

+0

异常'NSInvalidArgumentException',原因:'在iPad上,必须通过UIPopoverController呈现UIImagePickerController' – 2011-04-28 07:25:23

回答

0

尝试在iPad上流行过控制器呈现,不支持模式视图控制器

即使我遇到同样的问题,采用了流行的控制器,以便尝试和现在的作品:)

UIImagePickerController * picker = [[UIImagePickerController alloc] init]; 
picker.delegate = self; 
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; 

popControl = [[UIPopoverController alloc]initWithContentViewController:picker]; 

popControl.delegate=self; 
[popControl presentPopoverFromRect:browseButton.bounds inView:mainView permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES]; 
相关问题