我有一個UISplitViewController
這是一個UISplitViewControllerDelegate
具有以下的委託方法:UISplitViewController:如何呈現popover?
splitViewController:willHideViewController:withBarButtonItem:forPopoverController:
當iPad在肖像開始,我想酥料餅從SPLITVIEW可見。我怎樣才能做到這一點?
我試過下面的代碼:
- (void)splitViewController:(UISplitViewController *)svc
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem *)barButtonItem
forPopoverController:(UIPopoverController *)pc
{
//setting the barButtonItem in the toolbar in the detail view.
[pc presentPopoverFromBarButtonItem:barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
}
但上面的代碼給我下面的錯誤:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.'
凡在你的代碼,你把這個代碼?我嘗試過處理PopoverController指向我的ViewController的指針,但它似乎是當我想呈現popover時,將其更改爲nil。 – dhrm 2012-01-08 21:32:40
用工作和測試代碼更新了我的答案 – Darktau 2012-01-09 06:48:44
謝謝你,工作! – dhrm 2012-01-09 08:02:15