2017-10-11 62 views
0

如果我设置光栅化如下:重用UITableViewCell时,光栅化如何工作?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSString *const cellIdentifier = @"UITableViewCell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

    if (!cell) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 

    cell.layer.shouldRasterize = YES; 
    cell.layer.rasterizationScale = [UIScreen mainScreen].scale; 
    cell.textLabel.text = exampleTitles[indexPath.row]; 

    return cell; 
} 

据我所知,该系统应该为每个不同单元的图像缓存。但是如果每个单元格的标题都不一样呢?系统如何确定哪些缓存图像可用于特定单元?

回答

0

在WWDC14届419看后,我发现有两个规则:

  • 光栅化高速缓存的大小是有限的屏幕尺寸为25.5倍

  • 的光栅图像驱逐从高速缓存如果他们没有使用超过100ms

而在iPhone 6P做配置文件显示只有当前屏幕将被缓存。