我有一个带有自定义单元格的UITableView,这些单元格在xib文件中定义,在我的设备上当单元格上有UISegmentedControl时,滚动性能很差(不流畅)。NSLog语句显示单元格被分配和重用。下面是我cellForRowAtIndexPath方法的代码。根据苹果文档在xib中建立了连接。(在模拟器中平稳滚动)
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"TableViewCell"
owner:self
options:nil];
cell = self.tvCell;
self.tvCell = nil;
}
cell.layer.shouldRasterize = YES; // build error is here
UILabel *lbl = (UILabel *)[cell viewWithTag:1];
[lbl setText:[NSString stringWithFormat:@"Q%i", indexPath.row+1]];
return cell;
}