Looks like dumb question, but...:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.bar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 20.0, self.navigationController.view.bounds.size.width, HEADER_HEIGHT)];
my开发者_开发技巧SearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:bar contentsController:self];
mySearchDisplayController.delegate = self;
mySearchDisplayController.searchResultsDataSource = self;
mySearchDisplayController.searchResultsDelegate = self;
[self.navigationController.view addSubview:self.bar];
All behavior is working fine while i don't press a cancel or hided tableview. After that search bar is closed and i see a clear navigation bar, without search bar. I has change to viewDidload, but nothing changed.
Before start printing:
after:
Try to add searchbar as titleView for navigationBar. It may work.
Refer to this site:
http://iphonesdevsdk.blogspot.com/2011/04/custom-tableview.html
It may helps you
精彩评论