• ios 动态设置Cell高低


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

           self.mainTitle=[[UILabel alloc]init];
                self.mainTitle.numberOfLines=0;
                self.mainTitle.font=[UIFont fontWithName:@"Hiragino Sans GB" size:14];
                self.mainTitle.text=cell_info.title;
                self.mainTitle.textColor=[UIColor grayColor];
                CGSize titleSize=[self.mainTitle.text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width-20, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: self.mainTitle.font} context:nil].size;
                self.rowHeight=titleSize.height;
                self.mainTitle.frame=CGRectMake(15, 3, titleSize.width,titleSize.height);
                [cell.contentView addSubview:self.mainTitle];

           CGRect cellFrame=[cell frame];
            cellFrame.origin=CGPointMake(0,0);
            cellFrame.size.height=self.mainTitle.frame.size.height+5+self.imgOne.frame.size.height+5;
            [cell setFrame:cellFrame];

           return cell;

    }

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        if (indexPath.section==0) {
            return 160;
        }
        else{
    //        if (indexPath.row==0) {
    //            UITableViewCell *cell=[self tableView:self.tableView cellForRowAtIndexPath:indexPath];
    //            return cell.frame.size.height;
    //        }
            UITableViewCell *cell=[self tableView:self.tableView cellForRowAtIndexPath:indexPath];
            return cell.frame.size.height;
        }
    }

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    修改Tarsphp节点线程数避免请求阻塞
    Docker删除所有容器
    清理mysql数据库binlog日志
    查看centos磁盘情况,查找大文件路径
    winform窗体的生命周期和事件加载顺序是什么?
    数据库自增ID用完了会怎么样?
    MPFIT for python
    Plplot中line width 问题
    剪切Postscript图片中的多余边框
    嵌入式下的深度学习 Sparkfun Edge with TensorFlow(一)Hello World
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4853424.html
Copyright © 2020-2023  润新知