21

I'm sure there's something obvious I'm missing here, but I know that popover controls can have "titles", a header area that has a line of text above the content view (e.g. the "Tools" popover in iWork).

How can I add this in my own popovers?

Thanks.

Ben Zotto
  • 70,108
  • 23
  • 141
  • 204

2 Answers2

38

If you're using a UIPopoverController, just make its contentViewController to be a UINavigationController, and set the title of its deepest view controller.

If you're using a UIActionSheet, it has a title property already (which you should notice when initializing with -initWithTitle:….)

giampaolo
  • 6,906
  • 5
  • 45
  • 73
kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • This works, but it seems odd that you have to wrap you UIViewController in a UINavigationController just so the Title property can percolate back up to UIPopoverController. – Rupert Rawnsley Dec 22 '13 at 12:39
8

I have been beating my head against the wall all day with the same problem and I think I finally have the solution :D You need to use a UINavigationController for the popover's contentViewController, and then add a title to the navigations controller's navigation bar, like you normally would. Oddly, this doesn't work if you add a navigation bar to your existing view controller.

Scott H.
  • 81
  • 1