2

我有一个具有以下类的应用程序:

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

如何自定义 UISearchBar?我想添加一个分段按钮以允许搜索选项(和/或/短语)。

4

1 回答 1

7

试试这个:

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

这为您提供了标准的搜索分段控制。您可以使用search.selectedScopeButtonIndex它来检查它的状态。

于 2010-03-18T22:28:33.463 回答