繁体   English   中英

iOS5:UITableView 滚动性能差

[英]iOS5: UITableView poor scrolling performance

首先,我在滚动 tableview 时出现 memory 泄漏。 此处相同的问题。

此外,我的滚动速度足够快,但在我滚动时它“有点颤抖”。 细胞是可重复使用的。

代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    Country *country=[[self.items objectAtIndex:[indexPath section]] objectAtIndex:[indexPath row]];
    CountryCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell.imageView.image=[UIImage imageNamed:country.countryFlag];
    cell.countryName.text=country.countryName;
    cell.currencyCode.text=country.code;
    cell.currencyOriginalName.text=country.originalUnitName;

    return cell;
}

应用程序:iOS 5、ARC,Storyboard。

这种 tableView 行为的真正原因是什么以及如何解决它?

如果你的滚动在设备上很差,你可能没有在原型中正确配置你的子视图。 您在上述方法中没有做任何昂贵的事情。

使用 Core Animation 仪器(仅限设备)- 滚动时检查每秒帧数。 您希望尽可能接近 60fps。

打开“颜色混合层” - 任何透明的绘制都将以红色突出显示。 如果可能的话,您想从单元格中删除所有透明度,并使它们全部变为绿色。 这可能只是在原型子视图中正确设置背景颜色和不透明标志的问题。

如果您的图像与您的图像视图大小不同,那么每次出现单元格时您都将调整大小,这也是一项昂贵的操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM