我正在創建UISearchViewController
,我希望將UISearchBar
置於導航控制器的導航項中。以下是我沒有結果做到了:UISearchBar的範圍欄沒有在iOS 7中顯示?
self.searchBar = [UISearchBar new];
self.searchBar.showsScopeBar = YES;
self.searchBar.scopeButtonTitles = @[@"Users", @"Hashtags"];
self.searchBar.delegate = self;
self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
self.searchController.delegate = self;
self.searchController.searchResultsDataSource = self;
self.searchController.searchResultsDelegate = self;
self.searchController.displaysSearchBarInNavigationBar = YES;
我也試過:
self.searchDisplayController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
self.searchDisplayController.searchBar.scopeButtonTitles = @[@"Users", @"Hashtags"];
self.searchDisplayController.searchBar.showsScopeBar = YES;
我缺少了任何東西,或在這裏做錯了什麼?
你找到這是一個解決方案嗎?我遇到了同樣的問題 –
@KongHantrakool我還沒有找到解決方案。同時,我在導航欄中使用UISegmentedControl來完成範圍欄的工作。 – Ryan
感謝您的回答 –