我想在用户从 TableView 中选择某些内容后更改所选范围。 我试过这个:
for (id view in [self.searchDisplayController.searchBar subviews]) {
if ([view isMemberOfClass:[UISegmentedControl class]])
{
UISegmentedControl *scopeBar = view;
scopeBar.selectedSegmentIndex = 1;
}
}
但我想要的范围按钮仍然没有被选中。我的搜索栏没有类 UISegmentedControl 的 subview 。
最佳答案
我假设您指的是 UISearchBar
的范围,并且您已经设置了 UISearchBar
以显示范围。
UISearchBar 有一个需要设置的特殊属性:
self.searchDisplayController.searchBar.selectedScopeButtonIndex = 1;
关于ios - 如何以编程方式更改搜索栏中选择的范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26379865/