开发者

Empty Table with no data display

I having problem with my table. After loading everything. My data is being loaded and string into name and loadscore. However it will not show in the table. Please help.

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开发者_StackOverflow中文版];

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


Do you have the tableview delegate and datasource connected to your class?


if you are loading in this data after the view has appeared on screen check that you have reloaded the tables data source [yourTableView reloadData];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜