how to add navigation bar UISearchBar
// self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem: // UIBarButtonSystemItemAdd target:self action:@selector(addWord)] autore开发者_运维技巧lease];
with this i can add button to rightside to the naivation bar.
How to add UISearchBar in middle to the navigation bar.
I am not sure why you want the UISearchBar
on the navigation bar. Normally the implementation is just below the Navigation bar, and you can set it as your tableHeaderView
But for adding the Searchbar to your navigation bar, you cannot add the UISearchBar
directly. You can add the Navigation Bar, and your UISearchBar as subviews to a view (lets say comboView
) and then add it to your self.view
or your tableHeaderView
.
UIView * comboView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
[comboView addSubview:navigationBar];
[comboView addSubview:searchBar];
// You should have allocated the navigation bar and the search bar before this though.
self.tableView.tableHeaderView= comboView;
精彩评论