【发布时间】:2014-01-31 11:51:58
【问题描述】:
好吧,我又碰到了一个 iOS7 怪事:
我正在以编程方式将带有一些范围按钮的UISearchdisplayController + UISearchBar 添加到表格视图中。
现在,如果我选择搜索字段,则范围按钮太大。如果我切换到横向,情况会变得更糟,按钮严重错位。
这是我的代码(仅在标准的“主从应用程序”模板中添加了几行代码):
- (void)viewDidLoad
{
// ...
UISearchBar *searchBar = [[UISearchBar alloc] init];
searchBar.showsScopeBar = YES;
searchBar.scopeButtonTitles = @[@"one", @"two"];
self.tableView.tableHeaderView = searchBar;
self.mySearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
// ... add delegate, datasource, irrelevant for this example
}
这就是它的样子:
补充:
顺便说一句,如果我将事情与 IB 挂钩,也会出现错位。不过按钮宽度是正确的。
有人有解决方法的想法吗?
【问题讨论】:
标签: ios7 uisearchbar uisearchdisplaycontroller