回答

7

有不同风格的UITableVieWCell。在这里看到:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UITableViewCellStyle

我想你想使用UITableViewCellStyleValue1。

可以与相关风格初始化你的UITableViewCell:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableViewCell/initWithStyle:reuseIdentifier

当您使用有两个标签的样式,你可以使用为textLabel和detailTextLabel属性来分别设定他们。

0

不知道其中u认为你看到2个标签...你可以设置线属性的UILabels号码,如果你想要更多的线UILabel ref ....另外有一个UITableViewCell型UITableViewCellStyleSubtitle 包含一个detailTextLabel在UITableCell常规文本标签的顶部,所以你已经有一个内置的电池与2个文本字段,这里是一个裁判ref to UITableViewCell

2

您不必为了将内容添加到它的子类一个UITableViewCell。这里可能是带有额外标签的示例细胞生成方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *identifier = @"Identifier"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; 

    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease]; 

     UILabel *secondLabel = [[UILabel alloc] initWithFrame:cell.textLabel.frame]; 
     secondLabel.textAlignment = UITextAlignmentRight; 
     secondLabel.tag = 12345; 

     [cell.contentView addSubview:secondLabel]; 
    } 

    UILabel *second = [cell viewWithTag:12345]; 
    second.text = @"Second!"; 

    return cell; 
} 

让我知道您是否有任何问题。如有需要,我可以澄清一些事情。

+0

虽然在单元格的“contentView”中添加子视图功能强大且有用,但这些额外工作对于回答特定问题是不必要的。有关符合提问者要求的单元格示例,请参阅表格视图单元格样式。 – 2010-05-25 20:56:56

0

它不是2个标签,而是2个按钮,您需要在单元格的contentView视图中添加2个按钮。或者您可以创建页脚或页眉视图并添加这2个按钮。

相关问题