iOS5:UITableView滚动性能不佳

时间:2012-04-04 23:01:57

标签: objective-c ios uitableview storyboard

首先,我在滚动tableview越界时遇​​到内存泄漏。与here相同的问题。

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

代码:

- (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;
}

App:iOS 5,ARC,Storyboard。

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

1 个答案:

答案 0 :(得分:5)

如果设备中的滚动效果不佳,则可能未在原型中正确配置子视图。你没有在上面的方法中做任何昂贵的事情。

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

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

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