Xcode 6 iOS 8 UITableView rowHeight property retur

2019-05-23 06:01发布

This question already has an answer here:

I have a UITableView in Xcode in my project and I set rowHeight to be 44 in StoryBoard.

In iOS7 everything is fine but in iOS8 rowHeight returns a value of -1 which cause my table view not being displayed.

1条回答
成全新的幸福
2楼-- · 2019-05-23 06:45

In iOS 8, Apple introduces a new feature for UITableView known as Self Sizing Cells. If you want to display dynamic content in table view with variable height, you would need to calculate the row height manually.

tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension

Here is demo http://www.appcoda.com/self-sizing-cells/

查看更多
登录 后发表回答