How to add UISearchBar to NavigationBar via storyboard in iOS

I find what seems like an elegant answer to this question in How to add a search bar to the navigation bar for iPhone (one question, one answer: very short, so please watch).

I like the work on how to do this in a storyboard (aka IB): i.e. "create an output from the NavigationBar header in the SearchBar in IB." But where would I place the SearchBar on the storyboard?

Here is what I did:

  • I omitted the SearchBar in the TableView header
  • Then from the NavigatorBar I point the output to the SearchBar as a titleView (the only option)
  • But when I run the program, I get a failure: terminating with uncaught exception of type NSException.

The program also opened my code in

 int main(int argc, char * argv[])
 {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([MINAppDelegate class]));
    }
 }
+1
1

View (UIView) , , UISearchBar. .

+9

All Articles