• ios 实现 cell 的动态高度


    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
      Message *msgObj = _items[(NSUInteger) indexPath.row];
      NSString *msg = msgObj.content;
      CGFloat maxWidth = CGRectGetWidth(tableView.bounds);
    
      CGFloat msgCellWidth = maxWidth - MessageCellAvatarPadding * 2 - AVATAR_HEIGHT - MessageCellPadding-20;
      CGFloat height = [MsgCell heightForMessage:msg constrainedToWidth:msgCellWidth];
    
      return height+20;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      MsgCell *msgItemCell = [tableView dequeueReusableCellWithIdentifier:kMsgCellId forIndexPath:indexPath];
      Message *msg = self.items[(NSUInteger) indexPath.row];
      [msgItemCell setMessage:msg];
      return msgItemCell;
    }
  • 相关阅读:
    听说-- 迭代
    听说
    听说---时序图
    闪屏
    WBS
    听说
    Agile Development ----敏捷开发
    软件测试
    需求分析:WBS图
    2048小游戏
  • 原文地址:https://www.cnblogs.com/damnbird/p/4922784.html
Copyright © 2020-2023  润新知