起因很简单,就是跟着教程做,熟悉UITableView的使用,看到书上说cell有textLabel , imageview ,还有一个detailTextLabel,前面两个知道,但是后一个有点好奇,于是就试了一下,结果编译倒是没有问题,但是没有显示detailTextLabel,于是google吧,终于在这里 找到了答案。其实就是在初始化cell使用的参数不合适,换成下面代码中的
initWithStyle:UITableViewCellStyleSubtitle
就可以了。不行你试试。原谅我的low,为了认识什么叫header和footer我把它们也给打印出来了。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
static NSString *simpleTableIdentifier = @"AnimalsCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell == nil)
{
//cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [animals objectAtIndex:indexPath.row];
cell.detailTextLabel.text = @"this is a detail text";
/*
//if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
{
if ([cell.detailTextLabel.text length]==0)
{
cell.detailTextLabel.text = @"detail ";
}
NSLog(@"detail.lenght=%lu",[cell.detailTextLabel.text length]);
[cell layoutSubviews];
}
*/
// Configure the cell...
return cell;
}
补充说一下,其他类型的 style 在下面的官方链接中有具体的介绍 点击打开链接