UIPopoverControllerでなにかしらポップアップさせる時、一々UIViewControllerを新規クラスで作成するのが面倒な時ありますよね。
UIViewでの実装がすでにあるものをポップアップさせたい時とか。
こんな時はUIViewControllerを直接インスタンス化してそのviewにUIViewを割り当てればOKっぽいです。
(この辺がobjective-cらしいなーと思う所です)
UIViewController* popupContents = [[[UIViewController alloc]init]autorelease]; popupContents.view = [[XXXXView alloc]initWithFrame:CGRectMake(0, 0, 400, 400)]autorelease]; popupContents.contentSizeForViewInPopover = CGSizeMake(400, 400); //※1 UIPopoverController* popup = [[[UIPopoverController alloc]initWithContentViewController:popupContents]autorelease]; //アニメーション付きで表示する(ここは適当) [popup presentPopoverFromRect:CGRectMake(0, 0, 10, 10) inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
※1でcontentSizeForViewInPopoverを指定していますが、これが表示されるポップアップのサイズになります。