Adding UITableView to subview when searchbar is being edited
开发者_JAVA技巧I have a MKMapView with annotations on it and it works fine. I have a search bar as part of my navigation bar. When a user clicks on the search bar field I wanted to bring up a UITableView in code. I create a UITableView in the initialisation and want to add it to the sub view when - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar; gets called.
This all works fine but im trying to add it using [self.view addSubview:tableView] and nothing shows up. I've only ever made table views using UITableViewController so I'm a bit lost.
Thanks
I'd suggest creating a UITableViewController to control it, and then using presentModalViewController:animated: to show the tableview.
This was actually correct. I was just initialising it wrong not setting the bounds for it.
精彩评论