2012-11-09 40 views
1

我的iPad模擬器工作,我想在iPad的照片庫查看圖像,但它是有問題的:UIPopoverController沒有運行

「NSInvalidArgumentException」的,理由是:

「在iPad上,的UIImagePickerController必須通過UIPopoverController呈現」

這是我的代碼。幫我!

- (IBAction)ShowGallery:(id)sender { 
     if([UIImagePickerController isSourceTypeAvailable: 
      UIImagePickerControllerSourceTypePhotoLibrary]) { 
      picker = [[UIImagePickerController alloc]init]; 
      picker.delegate = self; 
      picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
      [self presentModalViewController:picker animated:YES]; 
     } 
+0

看到這個答案:http://stackoverflow.com/questions/9015155/how -to-使用-的UIImagePickerController功能於iPad的/ 9019460#9019460 –

回答

0

相反PresentModalViewController,你必須使用一個iPad.You可以PopoverController使用下面的代碼爲

UIPopoverController *popOver =[[UIPopoverController alloc] initWithContentViewController:picker]; 
    [popOver setPopoverContentSize:CGSizeMake(315.0 , 245.0) animated:YES]; 

    [popOver presentPopoverFromRect:takePictureButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];  
[picker release];