Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

ScrollView with dynamic content size

Can anyone explain to me how to make the content view of a scroll view size itself dynamically. I have labels which depending on what information is being loaded, they change sizes. How can I make it scroll to just past the bottom label. Currently I am just doing it manually by keeping the viewController in freeform. This does not look good though as the scrollView is not necessary for every selection from the tableView, only the ones with a large description label.

Jhoan Arango
Jhoan Arango
14,575 Points

Hey Brandon:

I would have to see your code, and what you are doing in order to help a bit. Perhaps load it somewhere so I can take a look ?

Sure, its actually on Github.

[https://github.com/Brandon-316/WOD-Guide]

Jhoan Arango
Jhoan Arango
14,575 Points

Ok, going to check it out.. where should I look into ?

The only part that uses a scrollview so far is the HeroWODDetailView. As you can see it is just set up as normal with the storyboard where I just made the view larger.

Jhoan Arango
Jhoan Arango
14,575 Points

For some reason I can't seem to run the project.. send me your e-mail so that I can send you an invite to a slack group, and in there you can explain better what you want.

Ok so I figured out I didn't have constraint between the lowest label and the bottom of the view. I still have a gap between the view and the scrollView at run time though however. I is corrected when I add a vertical constraint from the content view to the top of the container view but that causes the images constraints to go red now.

[https://www.dropbox.com/s/iggv5wi3gwpkibg/WOD%20Guide.zip?dl=0]