gpt4 book ai didi

iphone - 分组单元格显示在我的普通 tableView 中,我不知道为什么

转载 作者:行者123 更新时间:2023-12-03 21:18:43 26 4
gpt4 key购买 nike

所以我不知道这是怎么发生的,也不知道如何解决它,但我遇到了 UISearchDisplayController 的 plain tableView 显示带有分组单元格的搜索结果的问题。

我有一个带有几个名称的 dataSource 数组,一个 tableData 数组,它遍历 dataSource 数组并添加适合 searchText 的任何条目,然后根据它是哪个 tableView,我使用适当的 dataSource 重新加载 tableView 。 .

有人有想法吗?

代码:

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
int count = 0;

if(aTableView == self.tableView){
count = [userTableData count]==0?1:[userTableData count];
}else{
count = [tableData count];
}
return count;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return @"Users";
}

- (UITableViewCell *)tableView:(UITableView *)tView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"CellIdentifier";

// Dequeue or create a cell of the appropriate type.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
}

if(tView == self.tableView){
if([userTableData count] == 0){
cell.textLabel.text = @"Please select a user";
}else{
cell.textLabel.text = [userTableData objectAtIndex:indexPath.row];
}
}else{
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
}

return cell;

}

然后,当输入搜索时,匹配的字符串将添加到 tableData 数组中

最佳答案

为 UITableView 分配标签并在搜索时隐藏分组的 tableView

关于iphone - 分组单元格显示在我的普通 tableView 中,我不知道为什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7043558/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com