Dynamic UITableView Cell Height Based on Contents

前端 未结 12 686
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-05 07:29

I have a UITableView that is populated with custom cells (inherited from UITableViewCell), each cell contains a UIWebView that is auto

12条回答
  •  既然无缘
    2020-12-05 08:00

    Also i think such an algorithm will suit you:

    1) in cellForrowAtIndexPath you activate your webviews for loading and give them tags equal to indexPath.row

    2) in webViewDidFinishLoading you calculate the height of the content in the cell, and compose a dictionary with keys and values like this: key= indexPath.row value = height

    3)call [tableview reloadData]

    4) in [tableview cellForRowAtIndexPath:indexPath] set proper heights for corresponding cells

提交回复
热议问题