Ans :
For auto cell height in tableview in Swift 3.0
Write following 2 lines of code in viewDidLoad and before reload tableview :
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 44
Following steps must to do otherwise label height will not be increase and so UITableiViewCell.
Label height must be auto incremented using numberOfLines = 0
LineBreak should be set according your need word-wrap, char-wrap, etc...
For auto cell height in tableview in Swift 3.0
Write following 2 lines of code in viewDidLoad and before reload tableview :
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 44
Following steps must to do otherwise label height will not be increase and so UITableiViewCell.
Label height must be auto incremented using numberOfLines = 0
LineBreak should be set according your need word-wrap, char-wrap, etc...
Thanks. Using above way works for me.
ReplyDeleteI want to do more. As label height increase, my cell height should be increase as tableview height also should be increase. How can I achieve this?
Thank You
ReplyDeleteYou have to put bottom constraint for the UILabel.
ReplyDeleteBasically all the elements in the cell should have a constraint for top and bottom in order to push the bottom of the cell to expand.
Concurrently you can take help of stack views inside a tableView to help if the view becomes that complex