Ios UITableView中是否可以有主标题、副标题和UITableViewStyleValue1样式标题

Ios UITableView中是否可以有主标题、副标题和UITableViewStyleValue1样式标题,ios,objective-c,uitableview,Ios,Objective C,Uitableview,目前,我的tableView有一个主标题和一个两行的副标题: cell.textLabel.text = [shiftLength objectAtIndex:indexPath.row]; cell.detailTextLabel.numberOfLines = 2; cell.detailTextLabel.text = allDetail; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 如何在单元格右

目前,我的
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];

您可以添加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;

我建议您使用自定义单元格,并根据您的要求进行设置,而不是使用样式有限、限制不同的默认单元格

默认单元格仅在您必须实现某种最小功能时有用

是制作自定义单元格的好教程

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;

希望对您有所帮助。

检查修订版question@inVINCEable不要将标签添加为
accessoryView
的子视图,将其指定为
accessoryView
。它没有显示的原因是当您尝试将其添加为子视图时,
accessoryView
为零。您欢迎它,它肯定会对您有所帮助。