简体   繁体   中英

Auto layout cell based on subview or custom cell height

文字溢出储存格

In the image. Comments has a textview that has text overflown to below 3 cells . Ideally that should not happen.

I have a tableview with custom cells as xib files and some custom cells are subviews. Please let me know how to add auto layout for this subviews or xib's.

I read many posts they suggested.below code. But it doesn't work.

  1. In ViewDidLoad. self.tableView.rowHeight = UITableViewAutomaticDimension self.tableView.estimatedRowHeight = 50;

Please suggest a solution. Thank you.

它将起作用,但是每次输入新字符时都需要更新高度,因此,在cellForRow ,添加textview.delegate = self ,在textViewDidChange ,执行tableView.beginUpdate()tableView.endUpdate()单元格高度将正确更新

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM