问题描述
我正在开发一个仅限iPad的应用程序,我在UIViewController中有一个UITableView。我设置了一个 UISearchController 作为UITableView的标题。此搜索控件有三个范围。我希望范围选择器在搜索栏下方 。使用下面的代码,我可以在init处获得它,但是当我从输入开始时,选择器向右移动,并保持。
I'm developing a iPad-only app, and I've got a UITableView inside a UIViewController. I setted a UISearchController as the header of the UITableView. This search control has three scopes. I want the scope selector to be below the search bar. With the following piece of code, I'm able to get it at init, but when I start with the input, the selector goes to the right, and remains there.
这是一个动画:
以下是相关代码:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.searchBar.scopeButtonTitles = @[@"Uno",@"Dos", @"Tres"];
self.searchController.searchBar.delegate = self;
self.tableView.tableHeaderView = self.searchController.searchBar;
self.searchController.searchBar.showsScopeBar = YES;
self.definesPresentationContext = YES;
[self.searchController.searchBar sizeToFit];
提前致谢
推荐答案
我还在我的应用程序中加入了一个UISearchController。我正在使用Xcode 7.1。
I've also incorporated a UISearchController inside my app. I'm using Xcode 7.1.
我遇到了同样的问题,只是从我的代码中删除了self.searchController.searchBar.showsScopeBar。
I had the same problem and simply removed "self.searchController.searchBar.showsScopeBar" from my code.
将值更改为false或将其完全删除。
Either change the value to false or remove it completely.
self.searchController.searchBar.showsScopeBar = false
self.searchController.searchBar.showsScopeBar = false
这篇关于范围栏在UISearchController中的定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!