Using swift5 i tried below code but unable to make it a adjustable height of cell. Any one can help me in that?
tableView.rowHeight = tableView.frame.height/8
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
tableView.estimatedRowHeight = 100
return UITableView.automaticDimension
}
what I want
View Architecture
You need to confirm to UITableViewDelegate
and then call these two methods.
func tableView(UITableView, heightForRowAt: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
tableview.rowHeight = UITableView.automaticDimension
tableview.estimatedRowHeight = 100
But in both cases, it is required the views in cell have both bottom and top constraints. Read the accepted answer of this question for more info.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.