gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 22:09:54 25 4
gpt4 key购买 nike

目前我的 tableView 有一个主标题和一个两行的副标题:

cell.textLabel.text = [shiftLength objectAtIndex:indexPath.row];
cell.detailTextLabel.numberOfLines = 2;
cell.detailTextLabel.text = allDetail;

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

如何在单元格的右侧显示文本以代替附件类型?

我尝试在附件 View 中放置标签但没有任何显示

 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;

关于ios - 是否可以在 UITableView 中有主标题、副标题和 UITableViewStyleValue1 样式标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23174022/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com