我想在用户从表格视图中选择某些内容后更改所选范围。 我试过这个:
for (id view in [self.searchDisplayController.searchBar subviews]) {
if ([view isMemberOfClass:[UISegmentedControl class]])
{
UISegmentedControl *scopeBar = view;
scopeBar.selectedSegmentIndex = 1;
}
}
但我仍然没有选择我想要的范围按钮。我的搜索栏没有UISegmentedControl类的子视图。
答案 0 :(得分:2)
我认为您的意思是UISearchBar
的范围,并且您已经设置了UISearchBar
,因此它显示了范围。
UISearchBar有一个需要设置的特殊属性:
self.searchDisplayController.searchBar.selectedScopeButtonIndex = 1;