0

テーブル ビュー セルには 4 つのラベルがあります。最初にスクロールすると、テーブル ビューがスムーズに表示されません。すべてのセルが一度に表示された後、スクロールは問題なくスムーズです。それで、問題は最初に1つのセルをロードする速度だと思いました。

セルを再利用していますが、問題は解決しません。私を助けてください!本当にありがとう!

これが私のコードです:

// 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;    
}
4

1 に答える 1

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];
}
于 2011-09-29T04:31:38.990 に答える