search

Home  >  Q&A  >  body text

ios - UICollectionView is nested in UITableViewCell and I hope the height of the former changes according to the height of the latter

The layout method in

UICollectionView is similar to waterfall flow, and the contentSize of UICollectionView is determined according to the size of the text. I hope that the height of UITableViewCell can change according to the height of UICollectionView. How can I do it?

phpcn_u1582phpcn_u15822751 days ago755

reply all(3)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:21:36

    If you want to automatically calculate the tableview cell height, it is difficult to do it.
    You can first calculate the overall height of the collectionView, and then update the tableview cell height.
    For smoothness, the height can be cached.

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 13:21:36

    UICollectionView的高度、UITableViewCell height?
    Is it possible that the question was asked wrongly, and I didn’t understand the scene selection expressed by the poster?

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 13:21:36

    Write a cgfloat attribute in the tableview to record the height of the collectionview, and assign the value in the heightForRow method in the controller. It should be fine

    reply
    0
  • Cancelreply