gpt4 book ai didi

ios - UITableViewCell 的 detailTextLabel 没有使用所有可用空间

转载 作者:行者123 更新时间:2023-11-29 03:00:34 24 4
gpt4 key购买 nike

As shown in the screenshot

如截图所示。只是想知道如何要求详细文本标签利用所有可用空间,例如红色矩形的区域。我尝试设置detailTextLabel的框架以使宽度更大,但这不起作用。

提前谢谢你。

最佳答案

我建议您将 UITableViewCell 子类化,并将所有自定义单元格放入其中。它可能类似于以下代码:

CustomCell.h

@interface CustomCell : UITableViewCell

- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier;

@end

CustomCell.m

#import "CustomCell.h"

@implementation CustomCell

- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
if (self)
{
// Customization not related to positions and sizes of subviews. For example:
self.detailTextLabel.textColor = [UIColor lightGrayColor];
self.detailTextLabel.text = @"Aaaaaa…";
}

return self;
}

- (void)layoutSubviews
{
[super layoutSubviews];

// Customization related to positions and sizes of subviews. For example:
self.detailTextLabel.frame = CGRectMake(10.0, 10.0, 240.0, 40.0);
}

@end

关于ios - UITableViewCell 的 detailTextLabel 没有使用所有可用空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23351055/

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