重现UITableViewCell风格

时间:2011-07-26 10:26:24

标签: iphone ios uitableview

如何在不使用自定义单元格的情况下重现消息UITableViewCell样式?

目前,我正在使用UICellStyleWithSubtitle,我添加了附件,但我只能看到日期,并且隐藏了UITableViewCellAccessoryDisclosureIndicator。

我想要的是什么:

  

http://www.askdavetaylor.com/4-blog-pics/iphone-text-txt-message-haiti-2.png

我在做什么:

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 45, 15)];
    [myLabel setText:[NSString stringWithFormat:@"%@", [table returnDate]]];
    [myLabel setAdjustsFontSizeToFitWidth:YES];
    [myLabel setTextColor:[UIColor blueColor]];
    [myLabel setBackgroundColor:[UIColor clearColor]];
    cell.accessoryView = myLabel;
    [myLabel release]; 
    cell.textLabel.text = table.title;
    cell.detailTextLabel.text = table.subtitle;

2 个答案:

答案 0 :(得分:0)

试试这个,

cell.detailTextLabel.text = [table returnDate]

而不是使用label只需将值赋给 detailTextLabel ,并将单元格样式指定为 UITableViewCellStyleValue1

答案 1 :(得分:0)

为此,您不必使用CellStyle With Subtitle ..您可以使用UITableViewCellStyleValue1并尝试使用cell的detailTextLabel属性: cell.detailTextLabel.text = @"Yesterday";

相关问题