【问题标题】:Remove search bar from UISearchController on push推送时从 UISearchController 中删除搜索栏
【发布时间】:2016-05-27 18:03:54
【问题描述】:

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

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 : 推送前:

推送后:

对我来说发生了什么:

push 前后是一样的:

【问题讨论】:

    标签: ios objective-c uinavigationcontroller uisearchbar uisearchcontroller


    【解决方案1】:

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

    您可以从here下载 UISearchController 演示

    【讨论】:

    • 不,这不是重复的问题。该答案适用于过滤 uiseaechcontroller,self 是结果控制器,请在回答之前阅读问题
    • 我的意思是你可以跟随演示,不要展示 UISearchController 而是展示另一个持有 UISearchController 属性的视图控制器(我称之为 aVC)。选择结果表查看时,将DetailVC推入AVC.NavigationController。 span>
    • 好吧,演示并没有这样做,如果我这样做,我将失去 aninations
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-27
    • 2021-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多