I've a UISplitViewController
which is a UISplitViewControllerDelegate
with the following delegate method:
splitViewController:willHideViewController:withBarButtonItem:forPopoverController:
When the iPad is started in Portrait, I would like the Popover from the SplitView to be visible. How can I do that?
I've tried the following code:
- (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];
}
But the above code gives me the following error:
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.'
Best Answer
there only one problem, wrong place to call presentPopover method, splitViewController:*WillHide*ViewController....... so, barButtonItem exist but not present on screen. i used next code and it worked for me. For handle all cases u need to use 2 methods.
and