开发者

how to add navigation bar UISearchBar

开发者 https://www.devze.com 2023-03-17 12:25 出处:网络
//self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem: //UIBarButtonSystemItemAddtarget:self action:@selector(addWord)] autore开发者_运维技巧lease];

// 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; 
0

精彩评论

暂无评论...
验证码 换一张
取 消