Dynamic Cell's Height



This article will help you to resolve Dynamic cell's heigh Uitableview matter in IOS.
I found a solution and want to share to everyone.

To go a little further on Dao's answer.. 
He is correct, you need to use UITableViewAutomaticDimension
Also, you need to ensure that you setup your constraints in a way that all of the
 content in the cell is constrained to the cells contentView. So your label will likely
 need constraints such as
  • Leading constraint to ImageView
  • Top constraint to contentView
  • Bottom constraint to contentView
  • Trailing constraint to contentView
Make sure that you set the UILabel to multiline (or lines = 0) and it should work. 
If you are using the heightForRowAt delegate functions ensure you
return UITableViewAutomaticDimension
Copied From Stackoverflow

Nhận xét

Bài đăng phổ biến