2011-04-24 22 views
4

我有这个简单的代码:UITableView的字幕没有出现

- (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]; 
     cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton; 
    } 

    // Configure the cell... 
    NSString *subtitle = [NSString stringWithString: @"All about the color "]; 
    cell.detailTextLabel.text=subtitle; 
    cell.textLabel.text = [authorList objectAtIndex: [indexPath row]]; 

    return cell; 
} 

的问题是,我的字幕不appear.What我做错wrong.Please help.Thanks。

回答

23

你必须选择其他单元格样式,看文档:

UITableViewCellStyleDefault

简单 风格与文本标签 (黑色和左对齐的细胞)和一个 可选图像视图。请注意,这是 iOS 3.0之前的单元格的默认样式 。

你想要什么,我想,就是:

UITableViewCellStyleSubtitle

一种用左对齐的标签 在顶部和左对齐 一个单元格样式 以较小的灰色文本标记在它下面。 iPod应用程序使用 这种样式的单元格。

您可以参考iOS的表格视图编程指南章节Table View Styles and Accessory Views以查看样式及其外观的概述。