目前我的tableView
有一个主要标题和两行副标题:
cell.textLabel.text = [shiftLength objectAtIndex:indexPath.row];
cell.detailTextLabel.numberOfLines = 2;
cell.detailTextLabel.text = allDetail;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
如何在单元格的右侧发短信代替附件类型?
我尝试在附件视图中放置标签,但没有显示
UILabel *yourLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 300, 20)];
yourLabel.text = @"TEXT:";
[yourLabel setTextColor:[UIColor blackColor]];
[yourLabel setBackgroundColor:[UIColor clearColor]];
[yourLabel setFont:[UIFont fontWithName: @"Trebuchet MS" size: 14.0f]];
[cell.accessoryView addSubview:yourLabel];
答案 0 :(得分:1)
您可以添加UILabel作为单元格accessoryView
。或者你可以制作一个自定义单元格。
if (cell == nil) {
UILabel *yourLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 300, 20)];
[yourLabel setTextColor:[UIColor blackColor]];
[yourLabel setBackgroundColor:[UIColor clearColor]];
[yourLabel setFont:[UIFont fontWithName: @"Trebuchet MS" size: 14.0f]];
cell.accessoryView = yourLabel;
}
((UILabel *)cell.accessoryView).text = @"TEXT:";
cell.textLabel.text = [shiftLength objectAtIndex:indexPath.row];
cell.detailTextLabel.numberOfLines = 2;
cell.detailTextLabel.text = allDetail;
答案 1 :(得分:1)