views:

610

answers:

1

I've got an app with the following class:

@interface SearchViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate>
@property (nonatomic, retain) IBOutlet UISearchBar *search;

How can I customize UISearchBar? I'd like to add a segmented button to allow for search options (and/or/phrase).

A: 

Try this:

search.showsScopeBar = YES;
search.scopeButtonTitles = [NSArray arrayWithObjects:@"Button",@"Titles",@"Go",@"Here",nil];

That gives you the standard segmented control for search. You can use search.selectedScopeButtonIndex to check its state.

Tom
thanks. I note for future readers that you also have to add [search sizeToFit], otherwise the search bar will draw at its original size (i'm setting showsScopeBar in viewDidLoad).
Matt