我没有看到我的 UITableView 的文本显示。事实上,TableView 似乎根本没有出现在屏幕上,因为我无法选择空行。
奇怪的是,我在 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 吗?
最佳答案
您的字体颜色与背景颜色相同吗?如果将 accessoryType 设置为复选标记,它会显示吗?
cell.accessoryType = UITableViewCellAccessoryCheckmark;
关于iphone - UITableView 单元格文本不显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3833551/