空表没有数据显示

时间:2010-12-05 18:34:52

标签: iphone

我的桌子有问题。装完一切后。正在加载我的数据并将其串入名称和负载分数。但是它不会在表格中显示。请帮忙。

static const NSInteger kNameLabelTag = 1337;
static const NSInteger kScoreLabelTag = 5555;

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];


        UILabel *nameLabel = [[UILabel new] autorelease];
        [nameLabel setTag:kNameLabelTag];
        [cell.contentView addSubview:nameLabel];

        UILabel *highscoreLabel = [[UILabel new] autorelease];
        [highscoreLabel setTag:kScoreLabelTag];
        [cell.contentView addSubview:highscoreLabel];

    }
    // Configure the cell.

    //cell.textLabel.text = [loadhighScore objectAtIndex:indexPath.row];

    NSDictionary *score = [self.loadhighScore objectAtIndex:indexPath.row];

    NSString *name = [score objectForKey:@"ScoreName"];
    NSString *loadscore = [score objectForKey:@"HighScore"];

    [(UILabel *)[cell.contentView viewWithTag:kNameLabelTag] setText:name];
    [(UILabel *)[cell.contentView viewWithTag:kScoreLabelTag] setText:loadscore];




    return cell;
}

2 个答案:

答案 0 :(得分:0)

您是否已将tableview委托和数据源连接到您的班级?

答案 1 :(得分:0)

如果您在屏幕上显示视图后加载此数据,请检查您是否已重新加载表数据源[yourTableView reloadData];