IOS UItableview UIcollectionview cell高度自适应

               

1.tableviewcell 高度自适应

   主要方法:

  计算cell高度[cell.contentview systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];

      // NSLayoutConstraint 使用条件 添加相对约束

  ios 7.0 cell 高度计算修改:

   - (CGFloat)tableView:(UITableView )tableView estimatedHeightForRowAtIndexPath:(NSIndexPath )indexPath。 设置cell 高度估值

   - (CGFloat)tableView:(UITableView )tableView HeightForRowAtIndexPath:(NSIndexPath )indexPath  计算cell 显示高度

      在ios7之后 官方修改防止加载大量数据时计算所有cell的高度后才加载数据。

  计算高度需要返回值需要+1.

2.uicollectioncell 高度自适应 

   主要方法:

  计算cell高度[cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];

      // NSLayoutConstraint 使用条件 添加相对约束

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自blog.csdn.net/qq_43668118/article/details/86656667