Ben Lime
Ben Lime

Reputation: 493

UISearchBar in UINavigationBar can't add UIBarButtonItem

I'm trying to add a UISearchBar to a UINavigationbar using self.searchDisplayController.displaysSearchBarInNavigationBar = YES;

The UISearchBar gets added quite well into the UINavigationBar, but the left/right UIBarButtons are gone. I just can't figure out how to add them.

Andy ideas or examples on this?

Upvotes: 2

Views: 570

Answers (2)

Olla Ashour
Olla Ashour

Reputation: 301

For others viewing this thread, elaborating Ben's answer is what worked for me. [self.searchDisplayController.navigationItem setLeftBarButtonItem: self.sidebarButton];

Upvotes: 1

Ben Lime
Ben Lime

Reputation: 493

Dumb error from mine. When using self.searchDisplayController.displaysSearchBarInNavigationBar = YES; You need to use self.searchDisplayController.navigationItem to add the UIBarButtons. Now it is working properly.

Upvotes: 2

Related Questions