iphone使用自定义单元格滚动tableview的速度太慢

iphone使用自定义单元格滚动tableview的速度太慢,iphone,cocoa-touch,uitableview,Iphone,Cocoa Touch,Uitableview,我在iphone上部署应用程序时遇到了这个问题,模拟器上没有检测到这个问题 这是牢房的代码 - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"beginning cellforRowAtIndexPath for section %d, and cell %d",[indexPath indexAtPosition:0

我在iphone上部署应用程序时遇到了这个问题,模拟器上没有检测到这个问题

这是牢房的代码

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

    NSLog(@"beginning cellforRowAtIndexPath for section %d, and cell %d",[indexPath indexAtPosition:0],[indexPath indexAtPosition:1]);

    static NSString *MyIdentifier = @"MyIdentifier";
    NSString *fieldTitle;
    NSString*fieldDescription;
    [_stopWatch start];
    [PersonalSection GetField:&fieldTitle AndValue:&fieldDescription UsingIndexPath:indexPath AndPersonalInformation:_personalInfo];


    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"ViewContent" owner:self options:nil];
        cell = tvCell;
        self.tvCell=nil;

        ((UILabel*) [cell.contentView viewWithTag:1]).layer.cornerRadius=11;
        ((UILabel*) [cell.contentView viewWithTag:2]).layer.cornerRadius=11;
    }


    UILabel*mainLabel=(UILabel*) [cell.contentView viewWithTag:1];
    mainLabel.text=fieldTitle;
    //mainLabel.textColor = [UIColor colorWithRed:0.745 green:0.116 blue:0.176 alpha:1.0];

    UILabel*detailLabel=(UILabel*)[cell.contentView viewWithTag:2];
    detailLabel.text=fieldDescription;
    [_stopWatch stop];
    NSLog(@"---------End cellforRowAtIndexPath");

    return cell;
}
剩下的是部分,就像返回3或5没有真正的瓶颈。 所以我想知道是什么让它这么慢。 现在数据获取[PersonalSection GetField:&fieldTitle]相当快,它在iphone上的最大使用时间为0.1毫秒。问题出在其他地方,我猜有一种方法可以优化这段代码,我想知道自定义单元格的影响——它只是一个带有标签和文本字段链接到此ViewController的单元格。
任何想法。

当您创建单元格时,您将标识符设置为@cell,但当您将其出列时,您正在寻找@MyIdentifier。看起来您每次都在重新创建单元格。

当您创建单元格时,您将标识符设置为@cell,但当您将其出列时,您正在寻找@MyIdentifier。它看起来像您“您每次都会重新创建单元格,尽管如此。

好的,主要的性能问题是对contentview子视图的各个角落进行取整。 使用QuartzCore:

#import <QuartzCore/QuartzCore.h>
((UILabel*) [cell.contentView viewWithTag:1]).layer.cornerRadius=11;
我删除了这些控件,并减小了控件的大小,以适应分区表格的单元格。现在它们环顾四周,但文本字段和标签却没有。 这显著地改善了我的滚动性能。
谢谢大家的帮助。

好的,主要的性能问题是在contentview的子视图的各个角落设置圆角。 使用QuartzCore:

#import <QuartzCore/QuartzCore.h>
((UILabel*) [cell.contentView viewWithTag:1]).layer.cornerRadius=11;
我删除了这些控件,并减小了控件的大小,以适应分区表格的单元格。现在它们环顾四周,但文本字段和标签却没有。 这显著地改善了我的滚动性能。
谢谢大家的帮助。

事实上,我是在用同一个标识符排队,但这是一件错误的事情。但我发布了错误的代码,我只是更新了它。事实上,我是在用同一个标识符排队,但这是一件错误的事情。但我发布了错误的代码,我只是更新了它。这是我遇到的同一个问题解决这个问题的唯一方法是:使用UIImageView模拟拐角半径或按您所说的做。这与我的问题相同。解决这个问题的唯一方法是:使用UIImageView模拟拐角半径或按您所说的做。