我的表格视图单元格有四个标签。第一次滚动时,表格视图不流畅。在所有单元格显示一次后,滚动非常流畅,没有问题。所以我认为问题在于第一次加载一个单元格的速度。
我有重用单元,但问题没有解决。请帮我!非常感谢!
这是我的代码:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
NSArray *views = [[NSBundle mainBundle] loadNibNamed:@"ForumListTableViewCell" owner:self options:nil];
cell = [views objectAtIndex:0];
}
NSDictionary *cate = [_forums objectAtIndex:indexPath.section];
NSArray *forumsInCate = [cate objectForKey:@"forums"];
NSDictionary *forumInfo = [forumsInCate objectAtIndex:indexPath.row];
// title1
UILabel *forumTitleLabel = (UILabel *)[cell viewWithTag:1];
forumTitleLabel.text = [forumInfo objectForKey:@"name"];
// master
UILabel *masterLabel = (UILabel *)[cell viewWithTag:2];
NSString *master = [forumInfo objectForKey:@"moderators"];
masterLabel.text = master;
// title2
UILabel *threadTitleLabel = (UILabel *)[cell viewWithTag:3];
NSString *lastPostTitle;
NSDictionary *lastPostInfo = [forumInfo objectForKey:@"lastpost"];
lastPostTitle = [lastPostInfo objectForKey:@"subject"];
threadTitleLabel.text = lastPostTitle;
// author
UILabel *authorLabel = (UILabel *)[cell viewWithTag:4];
authorLabel.text = [NSString stringWithFormat:@"%@ / %@",
[forumInfo objectForKey:@"threads"],
[forumInfo objectForKey:@"posts"]
];
return cell;
}