首页 > 移动平台 > 详细

ios 实现 cell 的动态高度

时间:2015-10-30 12:28:24      阅读:319      评论:0      收藏:0      [点我收藏+]
- (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;
}

ios 实现 cell 的动态高度

原文:http://www.cnblogs.com/damnbird/p/4922784.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!