learner
learner

Reputation: 11800

How to add UISearchBar to NavigationBar through the storyboard in iOS

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

I like the piece about doing it in the storyboard (aka IB): i.e. "create an outlet from the NavigationBar titleView to the SearchBar in IB". But where would I place the SearchBar on the storyboard?

Here is what I did:

The program also opened my code in

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

Upvotes: 4

Views: 5131

Answers (1)

sean3033
sean3033

Reputation: 121

just drag a View (UIView) into navigation bar, then you can drag almost any UI element inside the view, including UISearchBar. I tried it and works for me.

Upvotes: 12

Related Questions