3

私はUIActionSheetを持っています。カメラまたは写真ライブラリから画像を選択するオプションがあります。このために私はimagePickerViewControllerを取った。カメラのためにそれは絶対にうまく動作します。しかし、写真ライブラリではありません。小さなpopupViewControllerフォトライブラリオプションに触れるにはIPadのUIActionSheetからuiimagepickercontrollersourcetypephotolibraryのためのUIImagePickerViewControllerを表示

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 

    if (buttonIndex == 0) 
    { 

     imgController = [[UIImagePickerController alloc] init]; 
     imgController.allowsEditing = YES; 
     imgController.sourceType = UIImagePickerControllerSourceTypeCamera; 
     imgController.delegate=self; 
     [self presentModalViewController:imgController animated:YES]; 

    } 
    else if (buttonIndex == 1) 
    { 

     if ([self.popoverController isPopoverVisible]) { 
      [self.popoverController dismissPopoverAnimated:YES]; 
      [popoverController release]; 
     } else { 
      if ([UIImagePickerController isSourceTypeAvailable: 
       UIImagePickerControllerSourceTypeSavedPhotosAlbum]) 
      { 
       UIImagePickerController *imagePicker = 
       [[UIImagePickerController alloc] init]; 
       imagePicker.delegate = self; 
       imagePicker.sourceType = 
       UIImagePickerControllerSourceTypePhotoLibrary; 
       imagePicker.allowsEditing = NO; 

       self.popoverController = [[UIPopoverController alloc] 
              initWithContentViewController:imagePicker]; 

       self.popoverController.delegate = self; 

       [self.popoverController setPopoverContentSize:CGSizeMake(500, 500)]; 

       [self.popoverController presentPopoverFromRect:self.view.frame 
                  inView:self.view 
             permittedArrowDirections:UIPopoverArrowDirectionAny 
                 animated:YES]; 


       [imagePicker release]; 
      } 
     } 


    } 

} 

は、ビューの上に作成されたが、それは非常に小さいです。 popupViewControllerが小さすぎるのはなぜですか? uiimagepickercontrollersourcetypephotolibraryUIImagePickerViewControllerを表示するための他の方法はありますか?

+0

あなたが望む通りにpresentPopoverFromRectのサイズを変更します。 – Hiren

答えて

3

CGRect popoverRect = [self.view convertRect:[self.view frame] 
             fromView:[self.view superview]]; 

    popoverRect.size.width = MIN(popoverRect.size.width, 80) ; 
    popoverRect.origin.x = popoverRect.origin.x+150; 

    [self.popoverController 
    presentPopoverFromRect:popoverRect 
    inView:self.view 
    permittedArrowDirections:UIPopoverArrowDirectionLeft 
    animated:YES]; 
-1

これを試してみてください:

imagePickerController = [[UIImagePickerController alloc] init]; 
imagePickerController.delegate = self; 
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
[self presentModalViewController:imagePickerController animated:YES]; 
+0

はiPhone上で動作し、iPadでは動作しません。また、申し訳ありませんが、downvoteは私がやりたかったものではありませんでした。 – TwiterZX

1

この例を試してみてください、私はあなたに渡すRECTは、全景の小さい、ではないサイズであるべきだと思う:

CGRect popFrom = CGRectMake (CGPointMake(50,50),10,10); 
[self.popoverController presentPopoverFromRect:popFrom 
                  inView:self.view 
             permittedArrowDirections:UIPopoverArrowDirectionAny 
                 animated:YES]; 
+0

CGRectMakeは4つのパラメータを受け入れます。しかしそれは助けになりました。 – Nitish

+0

ハハ、深夜のエラー、それを指摘してくれてありがとう...私はそれを固定しました、私はいくつかの助けだったうれしい:) – tams

1

UIImagePickerViewControllerのポップオーバーで提示しないようにしてみてください - 私はそれはタ自動的にケンケア!また、presentPopoverFromRect:CGRectは、viewのフレームを渡すときに間違っているように見えます。このフレームは、画面のほぼ中央を指すポップオーバーに変換されます。 UIActionSheetを提示したボタンのフレームにそれを設定したいかもしれません!

関連する問題