gpt4 book ai didi

iphone - 第一个 UITableViewCell 附件箭头没有显示

转载 作者:可可西里 更新时间:2023-11-01 05:24:03 25 4
gpt4 key购买 nike

这是我苦苦挣扎的代码,第一个表格单元格不显示辅助箭头,但其他表格单元格工作正常...

下面是表格单元格 1 的代码,其他单元格也已自定义但工作正常。

- (void) initialization
{
labelTitle = [[UILabel alloc] initWithFrame:CGRectZero];
labelTitle.font = [UIFont fontForMoreLikeResultTitle];
labelTitle.textColor = [UIColor blackColor];
labelTitle.numberOfLines = 1;
labelTitle.lineBreakMode = UILineBreakModeTailTruncation;
labelTitle.backgroundColor = [UIColor clearColor];

labelFulLAddress = [[UILabel alloc] initWithFrame:CGRectZero];
labelFulLAddress.font = [UIFont fontForMoreLikeResultDescription];
labelFulLAddress.textColor = [UIColor blackColor];
labelFulLAddress.numberOfLines = 1;
labelFulLAddress.lineBreakMode = UILineBreakModeTailTruncation;
labelFulLAddress.backgroundColor = [UIColor clearColor];

[[self contentView] addSubview:labelTitle];
[[self contentView] addSubview:labelFulLAddress];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
// Initialization code
[self initialization];
}
return self;
}

- (void) layoutSubviews
{
float xOffset = 20.0f;
float yOffset = 10.0f;
float currentUsedHeight = yOffset;

labelTitle.text = documentTitle;
labelTitle.frame = CGRectMake(xOffset, currentUsedHeight,
320.0f - 2 * xOffset, 60.0f);
[labelTitle sizeToFitHeight];
[labelTitle sizeToFitWidth];

labelFulLAddress.text = @"99999 Bellevue Way NE, Bellevue WA";
currentUsedHeight += (yOffset + labelTitle.frame.size.height);
labelFulLAddress.frame = CGRectMake(xOffset, currentUsedHeight, 320.0f - 2 * xOffset, 60.0f);
[labelFulLAddress sizeToFitHeight];
[labelFulLAddress sizeToFitWidth];
}

下面是 View Controller 中的代码:

- (UITableViewCell *) createResultTableCell1:(UITableView *)tableView{    static NSString *CellIdentifier = @"FirstMoreLikeResultCell";    FirstResultTableCell *cell = (FristResultTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];    if (cell == nil)    {        cell = [[MoreLikeTableCell1 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];        cell.selectionStyle = UITableViewCellSelectionStyleNone;        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;    }    cell.documentTitle = self.documentTitle;    return cell;}- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {       UITableViewCell *cell;    if (indexPath.row == 0)    {        cell = [self createResultTableCell1:tableView];    }    else    {        cell = [self createResultTableCell2:tableView cellForRowAtIndexPath:indexPath];    }    return cell;}

最佳答案

从您的覆盖layoutSubviews中调用[super layoutSubviews]

关于iphone - 第一个 UITableViewCell 附件箭头没有显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9844846/

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