关于searchbar的ScopeButton
|
self.searchBar.delegate = self;
self.searchBar.autocorrectionType = UITextAutocorrectionTypeNo; self.searchBar.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters; self.searchBar.placeholder = @"搜索"; self.searchBar.keyboardType = UIKeyboardTypeDefault; [self.searchBar setShowsScopeBar:YES]; [self.searchBar setScopeButtonTitles:[NSArray arrayWithObjects:@"分类",@"价格",@"销量", nil]]; self.searchBar.selectedScopeButtonIndex = 0; 继承 UISearchBarDelegate,UITableViewDataSource,UITableViewDelegate。(这里说一句,我在没有添加tableview之前,似乎没有效果出来的,具体什么原因,猜测可能要与tableview一起使用的吧) 下面是我实现delegate的具体方法: -(void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope{ NSLog(@"%d",selectedScope); }
|

浙公网安备 33010602011771号