gabicuesta
gabicuesta

Reputation: 339

Show various table views in a scroll view well fitted

I have a project for iOS 11.3 developed with Swift 4 and Xcode 9.3

In this project I have to show in the same screen the data of 4 different sources in 4 different tables ordered vertically.

I need to show the information read from the server in these tables that must grow or decrease height depending of the row number. And all the tables must be shown making the uiscroll grow without hide any of the other tables.

Data will be dynamic, so table 1 can have with the first item 4 rows and with other item 10 rows.

Is it possible with Swift 4 achieve this?

I have merged on one table all the data playing with the visual styles to simulate 4 tables, but I would prefer to have every data type in its own table view.

Thanks,

Upvotes: 0

Views: 49

Answers (1)

Ajay saini
Ajay saini

Reputation: 2470

you can achieve this by just doing.

  1. turn off scrolling of all tableViews
  2. Put all the tableViews inside the scrollView.
  3. give constraints to all tableview leading,trailing,top,bottom and height.
  4. while reloading the tableView calculate the content height of the each tableView and assign it to the height constraint of appropriate tableView.

Upvotes: 2

Related Questions