0

我想在用户从表格视图中选择某些内容后更改所选范围。我试过这个:

for (id view in [self.searchDisplayController.searchBar subviews]) {
    if ([view isMemberOfClass:[UISegmentedControl class]])
        {
            UISegmentedControl *scopeBar = view;
            scopeBar.selectedSegmentIndex = 1;
        }
}

但是我想要的范围按钮仍然没有被选中。我的搜索栏没有 UISegmentedControl 类的子视图。

4

1 回答 1

3

我假设您的意思是 an 的范围,UISearchBar并且您已经进行了UISearchBar设置,因此它显示了范围。

UISearchBar 有一个特殊的属性需要设置:

self.searchDisplayController.searchBar.selectedScopeButtonIndex = 1;
于 2014-10-21T15:34:33.683 回答