2011-08-28 136 views
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;  
} 
+0

您好像还初始化/页头你的变量。不认为其相关。我会尝试在模拟器和设备上查看这是否可重现。 – TommyG

+0

我已经在另一个函数中引入了所有变量,所以我认为它可能不是原因。我已经在模拟器中测试过它,它工作得很好。它在模拟器中非常流畅,但在iPhone中并不流畅。 – rexshi

+0

什么是iPhone/OS它慢? – TommyG

回答

0
NSArray *views = [[NSBundle mainBundle] loadNibNamed:@"ForumListTableViewCell" owner:self options:nil]; 

上.H

NSArray *views; 

上的.m

-(void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    views = [[NSBundle mainBundle] loadNibNamed:@"ForumListTableViewCell" owner:self options:nil]; 
} 

- (void)dealloc 
{ 
    //--- other object ---- 
    [views release]; 
    [super dealloc]; 
} 
+0

您无法重新使用视图。 –

相关问题