search

Home  >  Q&A  >  body text

ios - 自定义tableviewcell 被点击之后显示的内容消失

数据已经绑定上去了,运行时正常,但在点击表格内容时,格子里显示的内容消失
点击之前

点击之后

巴扎黑巴扎黑2771 days ago615

reply all(8)I'll reply

  • 巴扎黑

    巴扎黑2017-04-18 09:36:50

    Try setting Cell’s selectionStyle to none

    reply
    0
  • 黄舟

    黄舟2017-04-18 09:36:50

    This means that the cell size is not well controlled. Detached from actual size. What you have to do now is to re-set the frame when cell setdata. That way there's no problem.

    reply
    0
  • 阿神

    阿神2017-04-18 09:36:50

    I agree with @yangfanace’s idea.

    I don’t know how your subview is created and added to the cell, but when you click, the system will have a default click effect, which is gray.
    The default click effect of this system covers the subviews on the cell. So...

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:36:50

    Have you used the cellcontentViewproperty correctly?

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:36:50

    In the cellForRowAtIndexPath method, when displaying custom cell content based on row, try the return cell at the end of the if statement content

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 09:36:50

    @yangfanace Try setting Cell’s selectionStyle to none

    Perfectly solved my problem, thank you

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:36:50

    Give return cell after each judgment.
    -(UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    
    
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(!cell){
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    if(resultsArr.count == 0){
        cell.textLabel.text = @"暂无数据";
        cell.userInteractionEnabled = NO;
        cell.textLabel.font = [UIFont systemFontOfSize:14];
        return cell;
       
    }else{
        HouseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HouseTableViewCell" forIndexPath:indexPath];
        
           jingpingModel *tuijianmodel = [[jingpingModel alloc] initWithDic:resultsArr[indexPath.row]];
           IDarr[indexPath.row] = tuijianmodel.ID;
        NSLog(@"IDARR IS %@",IDarr);
           NSURL *picurl = [NSURL URLWithString:tuijianmodel.iconImage];
           [cell.iconImageview sd_setImageWithURL:picurl];
           cell.townnameLabel.text = tuijianmodel.area;
           cell.xiaoquName.text = tuijianmodel.name;
           cell.huxingLabel.text = tuijianmodel.houseType;
           cell.mianjiLabel.text = tuijianmodel.sqm;
           cell.shoujiaLabel.text = tuijianmodel.totalPrice;
           cell.isJishouLabel.text = tuijianmodel.status;
           cell.posttimeLabel.text = tuijianmodel.posttime;
           cell.selectionStyle = UITableViewCellSelectionStyleNone;
          return cell;
    }
    return cell;

    }

    reply
    0
  • 迷茫

    迷茫2017-04-18 09:36:50

    It’s not a matter of selecting the style, because the selected style won’t even cover the things inside the cell.

    reply
    0
  • Cancelreply