Home > Coding > UISearchBar to be the top item in the view

UISearchBar to be the top item in the view

January 22nd, 2009

Picture 1.png

So what to do if you’re building a view and you have a navigationBar at the top of the view but you want a searchbar at the top instead?

Try this in your viewDidLoad:

 self.navigationController.navigationBar.topItem.titleView = searchBar;

Of course you’ll need to define searchBar in the header file too…

IBOutlet UISearchBar *searchbar;

Along with doing all the NIB file stuff, property declarations, blah blah blah… but you get the idea.

Post to Twitter Tweet This Post

brandon Coding

  1. No comments yet.

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.