gpt4 book ai didi

ios - UItableview 可扩展单元格部分图像问题

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

我有关于部分图像的图像问题,当我展开单元格然后它在随机行中显示图像 ...

我必须在部分中显示 ImageView

图片+节中的节名

我的问题是图片显示在一些随机行的......

这是我的代码哪里错了??

    if (!indexPath.row)
{
// first row
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
client_Image = [[UIImageView alloc] initWithFrame:CGRectMake(10,10,50,50)];
client_Image.image = [UIImage imageNamed:@"mdclogo.png"];
[cell addSubview:client_Image];

cell.textLabel.text =[NSString stringWithFormat:@" %@",tclient.clientName];
UIFont *fontBold = [UIFont fontWithName:@"Arial Rounded MT Bold" size:30];
cell.textLabel.font = fontBold;
cell.textLabel.textColor = [UIColor blackColor];
}
else
{
cell.textLabel.text = [NSString stringWithFormat:@" %@",tclient.clientName];
UIFont *fontBold = [UIFont fontWithName:@"Arial Rounded MT Bold" size:20];
cell.textLabel.font = fontBold;
cell.textLabel.textColor = [UIColor blackColor];
client_Image = [[UIImageView alloc] initWithFrame:CGRectMake(5,5,39,36)];
client_Image.image = [UIImage imageNamed:@"mdclogo.png"];
[client_Image setClipsToBounds:YES];
[cell addSubview:client_Image];
cell.layer.cornerRadius = 0.5f;
cell.layer.masksToBounds = YES;
}
// only top row showing
if ([expandedSections containsIndex:indexPath.section])
{
cell.accessoryView = [DTCustomColoredAccessory accessoryWithColor:[UIColor grayColor] type:DTCustomColoredAccessoryTypeUp];
}
else
{
cell.accessoryView = [DTCustomColoredAccessory accessoryWithColor:[UIColor grayColor] type:DTCustomColoredAccessoryTypeDown];
}
}
else
{
// all other rows (client flows)
cell.textLabel.text = ((MDCFlowDetails * )[tclient.aflows getFlow:indexPath.row - 1]).title;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
cell.indentationWidth = 2;
UIFont *fontBold = [UIFont fontWithName:@"Arial" size:25];
cell.textLabel.font = fontBold;
cell.accessoryView = nil;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
else
{
cell.indentationWidth = 2;
UIFont *myFont = [UIFont fontWithName:@"Arial" size: 16.0 ];
cell.textLabel.font = myFont;
cell.accessoryView = nil;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}

最佳答案

当您滚动时,由于可重用性,图像添加到单元格中。试试下面的

 for (UIView *subview in [cell.contentView subviews]) 
{
if ([subview isKindOfClass:[UIImageView class]])
{
[subview removeFromSuperview];
}
}

也可以通过tag解决

关于ios - UItableview 可扩展单元格部分图像问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27186871/

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