O'Reilly logo

Programming iOS 4 by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Automatic Popovers

In a few situations, the framework will automatically create and display a popover for you. I am not personally fond of this behavior; the advantages of the automatic behavior (such as the fact that you do not have to provide code to create the popover) are counterbalanced, in my view, by the disadvantages — in particular, you can’t get access to the UIPopoverController, so the behavior and appearance of the popover is completely out of your hands.

One such situation is what happens when a search bar (a UISearchBar) tied to a search display controller (UISearchDisplayController) appears in a toolbar (UIToolbar) on the iPad. I’ll illustrate by rewriting the search bar code from Chapter 21. In this example, there’s a toolbar at the top of the screen, and in the nib editor we drag a search bar and search display controller (a single item in the Object library) into that toolbar. This single move puts a search bar in a bar button item into the toolbar and creates a search display controller at the nib’s top level, and configures all connections automatically, as follows:

  • The search bar’s delegate is the File’s Owner.
  • The File’s Owner’s searchDisplayController is the search display controller. This is a UIViewController property that I didn’t mention in Chapter 21, because its worth is not clear when a UISearchDisplayController is created and configured in code. When a UISearchDisplayController is instantiated from a nib, however, this property is an outlet that retains ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required