开发者

UISearchbar inside uinavigationcontroller

开发者 https://www.devze.com 2023-02-26 06:47 出处:网络
Looks like dumb question, but...: - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated];

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:

UISearchbar inside uinavigationcontroller

after:

UISearchbar inside uinavigationcontroller


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

0

精彩评论

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

关注公众号