gpt4 book ai didi

ios - UICustom 单元格在 iOS 7 中不显示标签

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

我添加了带有标签的自定义 UItableViewCell。标签在 iOS 6 中可见,但在 iOS 7 中不可见。

-(void)layoutSubviews{

[super layoutSubviews];
self.textLabel.frame = CGRectMake(90.0f ,-5.0f, 200.0f, 50.0f);
self.imageView.frame = CGRectMake(3.0f , 2.0f, 75.0f, 55.0f);

}


-(void)drawRect:(CGRect)rect{

self.imageView.layer.cornerRadius = 5;
self.imageView.layer.masksToBounds = YES;
self.imageView.layer.borderColor = [UIColor colorWithRed:0.0 green:0.4 blue:0.7 alpha:0.9].CGColor;
self.imageView.layer.borderWidth = 2;


[self.textLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:12]];
self.textLabel.backgroundColor = [UIColor clearColor];

[[UIColor grayColor] set];
[videoDurationTextLabel drawInRect:CGRectMake(90, 30, 190, 10) withFont:[UIFont fontWithName:@"Helvetica" size:12]];

[videoFileSizeLabel drawInRect:CGRectMake(170, 30, 190, 15) withFont:[UIFont fontWithName:@"Helvetica" size:12]];


}

TableViewController 类

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString *CellIdentifier = @"LazyTableCell";

VideoCustomCell *cell = [self.tblView dequeueReusableCellWithIdentifier:CellIdentifier];


if (cell == nil)
{
cell = [[[VideoCustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;

}

cell.textLabel.text = videoRecord.videoTitle;
cell.videoFileSizeLabel = [NSString stringWithFormat:@"%.4lfMb",totalSpaceInMB];
[cell.imageView setImage:[UIImage imageWithData: imgData]];
cell.videoDurationTextLabel = videoRecord.duration;

最佳答案

试试这段代码。

- (void) layoutSubviews {
[super layoutSubviews];
CGRect cvb = self.contentView.bounds;
CGRect imf = self.imageView.frame;
imf.origin.x = cvb.size.width - imf.size.width;
self.imageView.frame = imf;
CGRect tf = self.textLabel.frame;
tf.origin.x = 5;
self.textLabel.frame = tf;
}

- (void) viewDidLoad {

[super viewDidLoad];

UINib *cellNib = [UINib nibWithNibName:@"CustomTableCell" bundle:[NSBundle mainBundle]];
[self.tableView registerNib:cellNib forCellReuseIdentifier:@"CustomTableCell"];

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomTableCell";
CustomTableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if(cell == nil)
{
cell = [[CustomTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

cell.titleLabel.text ="test text";
[cell.imageView setImage:[UIImage imageWithData: imgData]];


return cell;
}

关于ios - UICustom 单元格在 iOS 7 中不显示标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25801696/

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