Reputation: 31323
This type of question has been asked before but here me out.
I have a UIViewController with two container views both of which embeds a table view.
The top tableview is dynamic while the bottom one is static. And there is a textfield inside a cell in the bottom tableview. So I want to scroll everything up when you tap the textfield and the keyboard appears. To do that I have put both the container views inside a scrollview.
I have the scrollview pinned to all four sides. And I have added leading, top, trailer constraints and also horizontal center constraint (I get a ambiguous scrollable content width error if not) to the top container view. And for the bottom container view, I added leading, bottom, trailing constraints. And also a vertical space constraint between the two container views.
But I still get the ambiguous scrollable content height error. I found that the answer to this issue is to ensure that you have enough constraints from top to bottom and I seem to have all of them. I can't figure out why I have this problem still. This is what it looks like when I run the app.
Am I missing something else?
Dropbox link to a demo Xcode project.
Upvotes: 1
Views: 2498
Reputation: 4176
The solution is embedding both containers in a view:
Then setting this view's constraints as these:
Then upper container's constraints:
Then lower container's:
Where proportional height constraint should look like:
with multipliers 0.6 for the upper and 0.4 for the lower containers.
Your project, edited: https://github.com/rshev/Example_EmbeddedTableViews
Upvotes: 1
Reputation: 10296
The first problem I see here is putting multiple views directly into a scrollview. Don't do that, instead put a single view (and name it containerView for example) with multiple views on it, and define constrains of containerView subviews that way so they will determine the content size of containerView. This way if you want your scrollView to scroll vertically only, all containerView subviews must have width equal to scrollview width and they should be placed from top to bottom to make scrollView scroll vertically
Upvotes: 0
Reputation: 2678
you have a scrollview, you must provide height constrain. add height constrain to your plain table view container and a height constain to your grouped view container.
Upvotes: 0