首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

UISearchDisplayController施用

2012-07-05 
UISearchDisplayController使用用UISearchBar初始化,设置代理UISearchBar *searchBar [[UISearchBar all

UISearchDisplayController使用
用UISearchBar初始化,设置代理

UISearchBar *searchBar = [[UISearchBar alloc] init];    self.tableView.tableHeaderView = searchBar;    [searchBar sizeToFit];    searchBar.delegate = self;    [searchBar release];        searchDisplay = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];    searchDisplay.delegate = self;    searchDisplay.searchResultsDataSource = self;    searchDisplay.searchResultsDelegate = self;


检测当前table view,分情况选择需要显示的数据

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {    if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]) {        return self.searchGroupList.count;    }    return [self.groupList count];}


cellForRowAtIndexPath同样选择

实现
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString;


用于重新填充搜索出的数据

热点排行