2010-12-05 63 views
0

我的桌子有问题。加载完所有内容后我的数据正在加载并串入名称和loadscore。但它不会显示在表格中。请帮忙。没有数据显示的空表

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; 
} 
+0

考虑改变你的初始[问题](http://stackoverflow.com/questions/4359786/how-do-i-display-the-data-saved-in-table),而不是发布一个新的同一主题 – vikingosegundo 2010-12-05 20:35:04

回答

0

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

+0

是的,我有。我发现的问题。主要问题是我不知道如何设置框架的大小 – lol 2010-12-06 00:30:50

0

如果你在载入这个数据后,视图出现在屏幕上,检查你已经重载了表数据源[yourTableView reloadData];