2010-12-05 89 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];