【问题标题】:How to show/hide a search bar inside a navigation bar (iOS 8) as in Apple's Calendar app?如何在 Apple 的日历应用程序中显示/隐藏导航栏(iOS 8)内的搜索栏?
【发布时间】:2014-11-07 16:21:37
【问题描述】:

如何实现:我有一个带有搜索图标的 UIBarButtonItem,点击它后,我想在导航栏中显示搜索栏,点击搜索栏中的取消按钮,我想在没有搜索的情况下显示导航栏IOS 7 日历应用中的按钮和标题。

【问题讨论】:

    标签: uibarbuttonitem searchbar


    【解决方案1】:

    为您的搜索按钮设置一个操作以显示UISearchController。请参阅 Apple 的 UICatalog sample code 中的 Search > Present Over Navigation Bar 演示:

    - (IBAction)searchButtonClicked:(UIBarButtonItem *)sender {
        // Create the search results view controller and use it for the UISearchController.
        AAPLSearchResultsViewController *searchResultsController = [self.storyboard instantiateViewControllerWithIdentifier:AAPLSearchResultsViewControllerStoryboardIdentifier];
    
        // Create the search controller and make it perform the results updating.
        self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
        self.searchController.searchResultsUpdater = searchResultsController;
        self.searchController.hidesNavigationBarDuringPresentation = NO;
    
        // Present the view controller.
        [self presentViewController:self.searchController animated:YES completion:nil];
    }
    

    【讨论】:

    • 你分享的链接很有用.. (+1)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多