I have been messing with these constraints for hours and cannot figure this out. I need to have Dynamic cell height with my text view.
As you can see its o
For Swift 3.1, 4.0
It will be achieved by setting constraints and UITableViewAutomaticDimensions
.
Step 1:
Step 2:
Step 3:
Step 4:
Remove Scrolling for UITextView
Step 5:
Add Below code,
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
Note:
If you have UILabel
then, Replace UITextView
to UILabel
from above solution and label.numberOfLines = 0
.
Output: