在推送时从UISearchController中删除搜索栏

时间:2016-02-16 12:40:34

标签: ios objective-c uinavigationcontroller uisearchbar uisearchcontroller

我有一个搜索栏图标,在按下时调用它:

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];

在我的SearchTableViewController.m文件中,我有一个成功调用的push segue:

 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];

然而,我没有得到预期的行为,即。

预计基于Apple Music的UISearchController: 推前: Before Push

推后: After Push

发生在我身上的事情:

推送前后相同: Before Push

1 个答案:

答案 0 :(得分:0)

这是一个重复的问题。 answer可能会有所帮助。

您可以从here

下载UISearchController演示