简体   繁体   中英

Remove search bar from UISearchController on push

I have a search bar icon that calls this upon being pressed :

SearchTableViewController *searchView = [[SearchTableViewController alloc]initWithNibName:@"SearchTableViewController" bundle:nil];
UINavigationController *navCtlr = [[UINavigationController alloc]initWithRootViewController:searchView];
UISearchController *searchController = [[UISearchController alloc]initWithSearchResultsController:navCtlr];
[searchController setDefinesPresentationContext:YES];
searchController.delegate = searchView;
searchController.searchResultsUpdater = searchView;
searchView.searchController = searchController;
searchController.searchBar.keyboardAppearance = UIKeyboardAppearanceDark;
[self presentViewController:searchController animated:YES completion:nil];

Inside my SearchTableViewController.m file, I have a push segue that is successfully called:

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
 DetailTableViewController *seeAll = (DetailTableViewController *) [storyboard instantiateViewControllerWithIdentifier:@"DetailTableViewController"];
 seeAll.query = self.searchController.searchBar.text;
 seeAll.title = @"Songs";
 [self.navigationController pushViewController:seeAll animated:YES];

However, i am not getting the expected behaviour ie.

Expected based on Apple Music's UISearchController : Before Push: 推前

After Push: 推后

And whats happening for me :

This is the same before and after push: 推前

Here is a duplication question. The answer may help.

You can download the UISearchController demo from here

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