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
searchDisplayControlleris 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access