Tableview滚动不是那么流畅吗

Tableview滚动不是那么流畅吗

我有一个包含三个不同自定义单元格的表格视图,每个单元格都将从三个不同的单元格类加载。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier1 = @"CellIdentifier";
    static NSString *CellIdentifier2 = @"Cell";
     static NSString *CellIdentifier3 = @"Cell";
    if (indexPath.section == 0)
    {
         CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1];

        if (cell == nil)
        {
            cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier1] autorelease];
        }
        cell.datelabel.text=@"dhhg";
      cell.nameLabel.text=@"shdhsjdj";
    cell.msg.text=@"sdhhhfhjhfj";

       cell.myImageView.image=[UIImage imageNamed:@"sd.png"];
        cell.likelabel.text=@"hhhf";

        return cell;

    }
    else
    {


        Customcellwithimage *cell = (Customcellwithimage *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier2];

        if (cell == nil)
        {
            cell = [[[Customcellwithimage alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier2] autorelease];
        }
        cell.datelabel1.text=@"sdhkhks";
        cell.nameLabel1.text=@"sdhjkhkshd";
        cell.msg1.text=@"sdsdsd";

        cell.myImageView1.image=[UIImage imageNamed:@"shdjhjhs"];
        cell.likelabel1.text=@"sjdh";
        cell.bannerview1.image=[UIImage imageNamed:@"dshjs"];

        return cell;
    }

 return Nil;

}


这是我的设计代码,有人在我出问题的地方可以帮助我吗?

最佳答案

造成延迟的原因可能是因为您是从主线程上的cellForRowAtIndexpath中的光盘加载的。尝试避免在主线程上进行I / O操作。在这里看看:loading images from a background thread using blocks

关于iphone - Tableview滚动不是那么流畅吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13172756/

10-14 21:55