我有一个包含很多行的 UITableView。每行都有一个 UIView,我在 cellForRowAtIndexPath 中进行了编辑。我的问题是这在 iPod touch 上非常滞后。我不确定为什么会发生这种情况,因为 iPod 应该能够一次在屏幕上显示超过 11 个 UIView?有谁知道为什么会这样?
编辑 - 这是代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIView *colorView = (UIView *)[cell viewWithTag:1];
UILabel *label = (UILabel *)[cell viewWithTag:2];
colorView.layer.cornerRadius = 10;
colorView.layer.borderColor = [UIColor blackColor].CGColor;
colorView.layer.borderWidth = 2.0f;
colorView.layer.masksToBounds = YES;
switch (indexPath.row) {
case 0:
label.text = @"White";
colorView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];
break;
case 1:
label.text = @"Olive";
colorView.backgroundColor = [UIColor colorWithRed:0.814 green:0.551 blue:0.119 alpha:1];
break;
case 2:
label.text = @"Dark Blue";
colorView.backgroundColor = [UIColor colorWithRed:0.036 green:0 blue:1 alpha:1];
break;
case 3:
label.text = @"Dark Green";
colorView.backgroundColor = [UIColor colorWithRed:0 green:0.387 blue:0.006 alpha:1];
break;
case 4:
label.text = @"Orange";
colorView.backgroundColor = [UIColor colorWithRed:1 green:0.500 blue:0 alpha:1];
break;
case 5:
label.text = @"Dark Brown";
colorView.backgroundColor = [UIColor colorWithRed:0.399 green:0.269 blue:0.137 alpha:1];
break;
case 6:
label.text = @"Dark Red";
colorView.backgroundColor = [UIColor colorWithRed:0.530 green:0.017 blue:0 alpha:1];
break;
case 7:
label.text = @"Maroon";
colorView.backgroundColor = [UIColor colorWithRed:0.502 green:0 blue:0.251 alpha:1];
break;
case 8:
label.text = @"Yellow";
colorView.backgroundColor = [UIColor colorWithRed:0.865 green:0.864 blue:0.002 alpha:1];
break;
case 9:
label.text = @"Purple";
colorView.backgroundColor = [UIColor colorWithRed:0.460 green:0 blue:0.865 alpha:1];
break;
default:
label.text = @"";
colorView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];
break;
}
return cell;
}
谢谢