Dynamic UIImageView Size Within UITableView

前端 未结 6 1370
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 13:46

I want to implement a TableView with a Custom TableViewCell showing an image.

To make this simple, I simply put a UIImageView inside a tableviewcell using autolayout

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 14:08

    Remove the height constraint from your imageView. Choose the contentMode of image view that starts with "aspect" eg: aspect fill or aspect fit (as it fits according to your requirements).

    NOTE: You also need to set the height of the row so that the imageView fits in it. Use

    heightForRowAtIndexPath
    

    to set custom row height.

提交回复
热议问题