UITableView根据名称数组索引或排序图像数组、描述数组



我正在使用UITableView。我正在显示名称、小描述和拇指url图像。我能够显示基于username(Name数组)的类的索引及其工作情况。

但是我的另一个数组(描述数组)和拇指URL图像(图像数组)没有正确显示数据。他们正在为新的部分重复自己。

我想要的:如果我把数组从A到Z排序,并显示索引。所有其他数组都应该以相同的方式排序。

现在,图像数组和描述数组正在为新节重复。

请帮忙。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    NSArray *listData =[self.tableContents objectForKey:
                        [self.sortedKeys objectAtIndex:[indexPath section]]];
    UILabel *lbl1 = [[UILabel alloc] init];
    lbl1.frame =   NSArray *listData =[self.tableContents objectForKey:
                        [self.sortedKeys objectAtIndex:[indexPath section]]];
    UILabel *lbl1 = [[UILabel alloc] init];
    lbl1.frame = CGRectMake(95, 02, 225, 25);
    lbl1.text = listData[indexPath.row];CGRectMake(95, 02, 225, 25);
    lbl1.text = listData[indexPath.row];

    UILabel *lbl2 = [[UILabel alloc] init];
    lbl2.frame = CGRectMake(95, 25, 230, 15);
    lbl2.text = date_array[indexPath.row];   //this one is not working
     return cell;
      }

我曾经遇到过类似的问题。重复是由于重用UITableViewCell造成的。

您可以将UILabel和UIImageView的值清除为上述函数的第一行,然后尝试运行代码。

最新更新