简体   繁体   中英

ios objective-c tableView searchBar

I have a hidden searchBar in a tableView header:

- (void)viewWillAppear:(BOOL)animated {    
    CGRect newBounds = self.tableView.bounds;
    newBounds.origin.y = newBounds.origin.y + self.searchBar.bounds.size.height;
    self.tableView.bounds = newBounds;
}

I also have a magnifying-glass icon button that reveals the search bar:

- (IBAction)showSearchBar:(id)sender {
    [self.searchDisplayController setActive:YES animated:YES];
    [self performSelector:@selector(showKeyboard) withObject:nil afterDelay:0.1];
}

Problem is, when I pull down the table (to reload data) - it also shows the search bar.

I only want the searchBar to become visible when the magnifying-glass icon gets tapped.

I am not really sure, how to address this problem?

Am I hiding it the wrong way in the first place?

Thanks,

Added a screenshot to make my question more clear: searchbar appears when pulling down

I don't tried that out, but I can image that you just have to hide it. for example: [[self.searchDisplayController view] setHidden:YES]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM