私は、特定のビュー コントローラーを設定しているポップオーバー コントローラーを生成するボタンがある iPad アプリで作業しています。UIPopoverController を生成し、特定のビュー (signUpListAddEditViewController) をロードするボタン コードを次に示します。
-(void)addSignUpList:(id)sender {
signUpListAddEditViewController = [[SignUpListAddEditViewController alloc] init];
popover = [[UIPopoverController alloc] initWithContentViewController:signUpListAddEditViewController];
popover.popoverContentSize = signUpListAddEditViewController.view.frame.size;
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
signUpListAddEditViewController.popover = popover;
}
SignUpListAddEditViewController.m 内には、いくつかのフィールドとテーブルビューがあります。フィールドの 1 つは UIButton で、画像を表示し、ユーザーがこのボタンを使用して新しい画像をロードできるようにします。既にポップオーバーになっているので、コンテンツ コントローラーを UIImagePickerController と交換します。ここまでは順調ですね。
-(void)takePicture:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[popover setPopoverContentSize:popupScreenSize animated:YES]; // popupScreenSize is a CGSIZE set to 500 x 900
[popover setContentViewController:imagePicker animated:YES];
}
ビューは、元のビューと同じサイズのまま imagePicker と交換され、さまざまな画像ギャラリー (カメラ ロール、フォト ストリームなど) を見ることができます。ここが奇妙になるところです。ギャラリーの 1 つを選択するとすぐに、ビューがそのギャラリー内の写真のサムネイル ビューに置き換えられ、その後、ビューの幅が大幅に狭くなります。画像がゆがんでおり、そのうちの 1 つを選択することはほぼ不可能です。
ポップオーバー コントローラーにアクセスする前に [popover setPopoverContentSize:CGSIZE animation:YES] を設定してみましたが、詳細な画像ビューを除いてすべてが適切にサイズ変更されていますか? サムネイル画像ギャラリー ビューをオーバーライドできるアイデアはありますか?
コンテンツ サイズを再度オーバーライドする didFinishPickingMediaWithInfo メソッドのコードを次に示します。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[thisList setThumbnailDataFromImage:image];
[popover setPopoverContentSize:popupScreenSize animated:YES];
[popover setContentViewController:self animated:YES];
listImageButton.imageView.image = image;
}