2010-09-30 96 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

相关问题