如何在 Apple 的日历应用程序中显示/隐藏导航栏(iOS 8)内的搜索栏? [英] How to show/hide a search bar inside a navigation bar (iOS 8) as in Apple's Calendar app?
本文介绍了如何在 Apple 的日历应用程序中显示/隐藏导航栏(iOS 8)内的搜索栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何实现:我有一个带有搜索图标的 UIBarButtonItem,点击它后,我想在导航栏中显示搜索栏,点击搜索栏中的取消按钮,我想在没有搜索的情况下显示导航栏IOS 7 日历应用中的按钮和标题.
How to implement: I have UIBarButtonItem with a search icon, after I click on it, I want to show the search bar in navigation bar and on click cancel button in search bar, I want to show navigation bar without search and with buttons and title like in IOS 7 calendar app.
推荐答案
为您的搜索按钮设置一个动作以呈现一个 UISearchController
.请参阅 Apple 的 UICatalog 示例代码:
Setup an action for your search button to present a UISearchController
. See the Search
> Present Over Navigation Bar
demo in Apple's UICatalog sample code:
- (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];
}
这篇关于如何在 Apple 的日历应用程序中显示/隐藏导航栏(iOS 8)内的搜索栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文