2010-09-30 97 views
3

我沒有看到我的UITableView顯示的文本..實際上,TableView並沒有出現在屏幕上,因爲我無法選擇空行。UITableView單元格文本沒有顯示?

奇怪的是,我在cellForRowAtIndexPath中的日誌顯示了預期的數據 - 我只是在屏幕上看不到任何內容。

-(void)bindFriendsToTable:(NSArray *)friends{ 
NSLog(@"friends : %@",friends); 
[sections removeAllObjects]; 
[sectionRows removeAllObjects]; 

[sections addObject:@"Friends"]; 
[sectionRows setObject:friends forKey:@"Friends"]; 

[self.tableView reloadData]; 
HideActivityIndicator(); 

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
NSString *cellsection = [sections objectAtIndex:indexPath.section]; 
NSArray *rowsInSection = [sectionRows valueForKey:cellsection]; 

static NSString *CellIdentifier = @"Cell"; 

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

cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:14]; 
[cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
cell.textLabel.text = [rowsInSection objectAtIndex:indexPath.row]; 
NSLog(@"%@",cell.textLabel.text); 

return cell; 

}

我從一個基類,它是一個UITableViewController,因爲我有項目等十多種屏幕繼承。任何想法,爲什麼我沒有看到tableView?

回答

2

你有任何標題部分?如果是的話請確保您heightForHeaderInSection返回值:

-(float)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ 
     return 66; 
} 
+0

忘了設置!謝謝。 – quantumpotato 2010-09-30 19:42:36

3

您的字體顏色與背景顏色相同嗎?如果您將accessoryType設置爲複選標記,它會顯示?

 cell.accessoryType = UITableViewCellAccessoryCheckmark; 
+0

感謝您的回覆。不,我沒有看到配件。我試着評論selectionStyle的東西,並不能選擇行。 – quantumpotato 2010-09-30 18:52:27

+0

嗨@利用我可以看到複選標記。但仍然沒有文字..甚至改變單元格的背景顏色和文本標籤:/ – StinkyCat 2013-08-01 11:29:00

+0

編輯:剛發現表的左側是在一個視圖後面,因此我認爲這些單元格是空的,但沒有。 THKS! – StinkyCat 2013-08-01 12:29:08

-2

我覺得你應該刪除 [細胞setSelectionStyle:UITableViewCellSelectionStyleNone]。 然後嘗試一下。 並在單元格中顯示另一個靜態字符串以檢查問題。

+0

從文檔中,「選擇樣式是一個backgroundView常量,它決定了單元格在選中時的顏色,默認值爲UITableViewCellSelectionStyleBlue。有關有效常量的描述,請參見」單元格選擇樣式「。 – quantumpotato 2011-08-10 04:27:45

相關問題