0

I want to change the selected scope after user has selected something from a table view. I have tried this:

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

But the scope button i want is still not selected. My search bar doesn't have a subview of class UISegmentedControl.

Manolis Karamanis
  • 758
  • 1
  • 10
  • 27

1 Answers1

3

I assume you mean the scopes of an UISearchBar and you already have your UISearchBar set up so it shows scopes.

The UISearchBar has a special property that needs to be set:

self.searchDisplayController.searchBar.selectedScopeButtonIndex = 1;
Jan Bühler
  • 421
  • 3
  • 18