【问题标题】:UISwitch detailed text underneathUISwitch 详细文字下方
【发布时间】:2017-06-08 18:17:46
【问题描述】:

我希望能够将描述性文本放在标签下方。以下是我到目前为止的代码:

UISwitch *toggle = [[UISwitch alloc] init];
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Cell"];
    cell.textLabel.text = @"Remote Execution";
    cell.detailTextLabel.text = @"Remote execution will permit registered devices to execute tests without manually starting them";
    [cell addSubview:toggle];
    cell.accessoryView = toggle;
    [cell.detailTextLabel setAlpha:1.0];
    [cell.detailTextLabel setTextColor:[UIColor redColor]];

【问题讨论】:

    标签: ios objective-c uitableview uiswitch


    【解决方案1】:

    使用UITableViewCellStyleSubtitle 代替UITableViewCellStyleValue1

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];
    

    【讨论】:

    • 这行得通,但我的消息似乎很长,下面有 1 行。有什么办法可以让它在下面分成两行?谢谢!
    • 每个单元格都有相同的信息吗?有时只有 1 行,有时只有 2 行吗?甚至3行?如果设备旋转到横向呢?最好的办法是创建一个自定义单元格并为动态高度单元格使用自动布局。
    • 我只是设置了 cell.detailTextLabel.numberOfLines = 2;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-16
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 2013-01-17
    • 2018-07-26
    • 1970-01-01
    相关资源
    最近更新 更多