I have tried to hard code the row height in the table view cell. After running the program it looks like only one line. I suspect it is because of the height of the row of the table view.
Could you please tell me what went wrong in here?
To get dynamic cell heights working properly, you need to create a custom table view cell and set it up with the right Auto Layout constraints. In the project navigator, select the Views group and press Command-N to create a new file in this group.
To change the height of tableView cell in ios dynamically, i.e resizing the cell according to the content available, we'll need to make use of automatic dimension property. We'll see this with the help of an sample project.
Add this code in your UITableViewDelegate
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 100 }
In Xcode 9, tableview
automatically create estimated cells based on Autolayout
. Since you have not provide autolayout, that's why you are getting this.
You need to disable estimated and automatic cell size by selecting tableview and uncheck the two options:
Give value you want to Row height, and cell will be created accordingly.
Hope this can help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With