0
我的表格視圖單元格有四個標籤。 第一次滾動時,表格視圖不平滑。所有單元格顯示一次後,滾動非常順暢,沒有問題。 所以我認爲問題是第一次加載一個單元格的速度。爲什麼我的UITableView在第一次滾動時不平滑?
我有重用單元,但問題沒有解決。請幫幫我!非常感謝!
這裏是我的代碼:
// 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;
}
您好像還初始化/頁頭你的變量。不認爲其相關。我會嘗試在模擬器和設備上查看這是否可重現。 – TommyG
我已經在另一個函數中引入了所有變量,所以我認爲它可能不是原因。我已經在模擬器中測試過它,它工作得很好。它在模擬器中非常流暢,但在iPhone中並不流暢。 – rexshi
什麼是iPhone/OS它慢? – TommyG