zoukankan      html  css  js  c++  java
  • 根据label不同的字符串的多少自适应cell的高度

     //获取评论内容 根据内容来设置label的高度  设置tag值

            NSString *string = [NSString stringWithFormat:@"%@",label.text];

            CGRect rect = [string boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width -70, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil];

            cell.content.frame = CGRectMake(60, 40,[UIScreen mainScreen].bounds.size.width -70 , rect.size.height);

            cell.content.tag = 11;

            cell.content.text =string;

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

    {

        //根据tag值来获取cell的高度

        UILabel *nameLabel = (UILabel *)[self.view viewWithTag:1];

        UILabel *contLabel = (UILabel *)[self.view viewWithTag:11];

        return nameLabel.frame.size.height+contLabel.frame.size.height + 30;

    }

  • 相关阅读:
    Shiro安全框架之集成 Web(下)
    Shiro安全框架之集成 Web(中)
    Shiro安全框架之集成 Web(上)
    01背包
    巴什博弈
    斐波那契博弈
    一. 至少转最多
    平面分割类问题
    求凸包(安德鲁算法)
    GCD和exGCD
  • 原文地址:https://www.cnblogs.com/Lovexiaohuzi/p/5474464.html
Copyright © 2011-2022 走看看