2011-06-09 20 views
0

我使用基於application.so我用下面的代碼顯示它在ipad UIImage的選擇器控制:如何將UIImagePickerController控制器添加到基於ipad的應用程序以顯示多個圖像?

[self presentModalViewController:myImagePicker animated:YES]; 

但顯示

'On iPad, UIImagePickerController must be presented via UIPopoverController' 

我如何添加一個一個的UIImagePickerController錯誤控制器到我的基於ipad的應用程序來顯示多個images.can任何一個爲我提供了一個很好的方法來做到這一點。

+0

看到這個答案http://stackoverflow.com/a/9019460/78336 – neoneye 2012-08-18 19:38:30

回答

0

是否這樣做。當你點擊按鈕動作中的按鈕時,請調用它。

UIActionSheet *photoActionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose Existing",nil]; 

     [photoActionSheet showFromRect:CGRectMake(315, 355, 10, 10) inView:self.view animated:YES]; 
+0

你不需要保留。 – 2011-06-09 11:36:24

+0

'NSInvalidArgumentException',原因:' - [UIPopoverController modalTransitionStyle]:無法識別的選擇器發送到實例0x644a990' – Christina 2011-06-09 11:37:06

+0

請看看答案 – Tendulkar 2011-06-09 11:51:22

0
#pragma mark UIActionSheetDelegate methods 

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ 
    imgPicker.delegate = self; 


    if(buttonIndex == 0){ 

      if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ 
       imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
       [self presentModalViewController:imgPicker animated:YES]; 

     } 


    else if(buttonIndex == 1){ 


      imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
      [self presentModalViewController:imgPicker animated:YES]; 


    } 

} 
+0

'NSInvalidArgumentException',原因:'在iPad上,UIImagePickerController必須通過UIPopoverController' – Christina 2011-06-09 12:46:53

+0

讓你知道我的問題是「我在基於ipad的應用程序中使用uiimage picker控件」 – Christina 2011-06-09 12:49:39

相關問題