I'm embedding a UITableView
inside of another UIScrollView
. I only want the UIScrollView
to scroll, not the UITableView
, so I want to disable the scrolling in UITableView
, as well as expand the contentHeight
for the UITableView
to accommodate all dynamic at once.
How would I go about doing this?
UITableView is a scroll view. While you are not supposed to nest UIScrollviews, you can disable scrolling of the the table view.
Set tableView scrolling property to false.
First Approach:
Create a subclass for tableView and override intrinsicContentSize.
In Interface builder change the class of your tableView to MyOwnTableView (subclass UITableView).
Set automatic row height for the table view.
Second Approach: 1. Create a height constraint with any value for tableView and connect an IBOutlet that sets the tableView height.
Set the height constraint's constant to tableView.contentSize.height after reloading the data.