【问题标题】:UItableview Expandble Cell Section Image issueUItableview Expandble 单元格部分图像问题
【发布时间】:2014-11-28 10:38:23
【问题描述】:

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

我必须在部分中显示图像视图

图片 + 部分中的部分名称

我的问题是图像显示在 Some random Row's ...

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

    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;
        }
    }

【问题讨论】:

    标签: ios objective-c uitableview ios7 ios8


    【解决方案1】:

    当您因为可重用性而滚动时,图像会添加到单元格中。试试下面的一个

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

    你也可以用tag解决

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-16
      • 1970-01-01
      • 2016-07-08
      • 2013-04-07
      • 2014-12-02
      • 1970-01-01
      相关资源
      最近更新 更多