我正在使用UISearchDisplayController进行搜索,并希望在每个单元格中添加更多元素(如果可能的话).做了一些搜索但找不到任何信息.唯一的方法是使用tableview重现它.是否还有其他属性可以设置为textlabel.text
提前致谢!
您可以完全更改单元格.
以下代码段依赖于UITableCell,ANormalCell和ASearchCell的两个子类.
警告:这段代码还没有编译,但你得到了要点?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *normalCellReuseIdentifier = @"ANormalCell";
static NSString *searchCellReuseIdentifier = @"ASearchCell";
UITableViewCell* cell = nil;
if (tableView != self.searchDisplayController.searchResultsTableView) {
cell = (ANormalCell*)[self.tableView dequeueReusableCellWithIdentifier:normalCellReuseIdentifier];
if (cell == nil) {
NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ANormalCell" owner:nil options:nil];
cell = (ANormalCell*)[topLevelObjects objectAtIndex:0];
}
} else {
cell = (ASearchCell*)[self.tableView dequeueReusableCellWithIdentifier:searchCellReuseIdentifier];
if (cell == nil) {
NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ASearchCell" owner:nil options:nil];
cell = (ASearchCell*)[topLevelObjects objectAtIndex:0];
}
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5485 次 |
最近记录: |