0

I'm making an iPad application using a UISplitViewController. I want the masterView visible in a UIPopoverController when the app starts (and only when it starts) in portrait mode. If I use the presentPopoverFromBarButtonItem:permittedArrowDirections:animated: method in the splitViewController:willHideViewController:withBarButtonItem:forPopoverController: delegate function, I get the following error, when I start the app in portait mode:

Popovers cannot be presented from a view which does not have a window.

Can anybody help me?

Costique
  • 23,712
  • 4
  • 76
  • 79
Vincent Osinga
  • 1,043
  • 7
  • 15

1 Answers1

0

The particular error says that you must add the view to a window before showing the popover, not the other way round. Try sending presentPopover… from the application delegate's -application:didFinishLaunchingWithOptions: after adding the view to your app's window.

Costique
  • 23,712
  • 4
  • 76
  • 79
  • It works but the only strange thing is that the popover shows some 40 pixels lower than when you push the barbuttonitem later on... – Vincent Osinga Dec 11 '10 at 15:05
  • It may happen because the view hasn't performed layout with its final bounds. Try sending the view controller's view `layoutIfNeeded` after adding it to the window. – Costique Dec 11 '10 at 16:15