Reputation: 6829
I am trying to implement UISearch bar but I have some problems. When app starts I add table view like this:
ChannelTableViewRootController *firstViewController = [[ChannelTableViewRootController alloc] initWithStyle:UITableViewStylePlain];
navigationController = [[UINavigationController alloc]initWithRootViewController:firstViewController];
navigationController.navigationBar.hidden = NO;
UIView *uv = self.view;
[uv addSubview:[navigationController view]];
I add UISearch bar in xib. Connect it to UISearchBar variable from my header file. Set delegate to self, and try to add it to header of tableview:
self.tableView.tableHeaderView = searchBar;
searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
And when I make object manually 'searchBar = [[UISearchBar alloc]init]; // + code from above
' I got displayed search bar like on image but nothing happends and can't put it over that header. I am trying to make search like in address book with scopes etc.
Upvotes: 0
Views: 1175
Reputation: 16543
Have you tried to create the searchbar with the initWithFrame. Try giving Values to it and adding subView to the view not on header. I think you have some mistake in positioning.
You also specified that you added UISearchbar in xib and also you have allocated in the coding also. Dont do that its a wrong way. Do any one of them i suggest you if you add tableView programatically then add searchbar programatically. Or assign them both in Xib.
Otherwise have a look at this tutorial
http://ved-dimensions.blogspot.com/2009/02/iphone-development-adding-search-bar-in.html
Upvotes: 1