You must do this programmatically. Here is what I ended up doing. First add the following to the .h file of your ViewController.
@interface YourViewController : UITableViewController <UISearchBarDelegate> { UISearchBar *mySearchBar; } @property (nonatomic, retain) UISearchBar *mySearchBar; @end
Then put this code in the viewDidLoad method of my RootViewController.
self.mySearchBar = [[[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 64.0, self.view.bounds.size.width, 44.0)] autorelease]; self.mySearchBar.delegate = self; self.mySearchBar.showsCancelButton = YES; self.mySearchBar.hidden = YES; self.mySearchBar.tintColor = [UIColor lightGrayColor]; [self.navigationController.view addSubview: self.mySearchBar];
You may also need to add something like this to prevent the searchBar from being on top of your TableView.
self.tableView.frame = CGRectMake(0.0, 44.0, 320, 324);
In my case, the searchBar remained in the view when I expanded to the detailed view. I had to call:
self.mySearchBar.hidden = YES;`
In my didSelectRowAtIndexPath to get rid of it when I click on a cell.
Jonah source share