0

As shown in the screenshot

As shown in the screenshot. Just wondering how can I ask the detailTextLabel to make use all of the available space, say, the area of the red rect. I tried to set the frame of the detailTextLabel to make the width bigger which just doesn't work.

Thank you in advance.

4

2 回答 2

1

我建议您将 a 子类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
于 2014-04-29T21:23:37.003 回答
0

让我们尝试风格UITableViewCellStyleDefault

YourViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
    cell = [[YourViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
于 2014-04-29T01:56:49.420 回答