Scroll View School · Challenge: Auto Layout | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9223-scroll-view-school/lessons/10

I accidentally added the bio text to the text view after I put everything into a stack view. Now the text view does not stretch to the bottom of the screen. Is their a way to fix this without removing the stack view and starting over

Hi! It shouldn’t matter what order you do those two steps in, as long as you go through all of the other steps (I just did a trial run to check). Make sure you’ve changed the bio’s font size to “Body” and unchecked “Scrolling Enabled”. If it still doesn’t look right, double check your constraints.

You can also upload a screenshot if you’re still having issues, so I can see what you’re seeing. :]

I solved it. I had Fill Equally instead of Equal Spacing on the stack view.

1 Like

Sorry but following this no longer works. Followed i exactly (twice) but the result is not the same as in the End-project (witch works). Can’t understand why, perhaps the Content and Frame layout guides thats not present in the end-project.

@tonjac Do you still have issues with this?

Hi! Yes, the content & frame layout guides change things a bit. I’m working on getting a few updated instructions and starter/final projects uploaded for this course this week. I’ll let you know when this one is up!

In the mean time, if you haven’t seen it yet, this forum thread may help you out: Scroll View School · Embedding Layouts | raywenderlich.com

Hello again! I have updated the materials for this episode to include an End project for iOS 13.

Scroll Views now have a Content Layout Guide and Frame Layout Guide in Interface Builder! This actually makes the work of using auto layout a little more straightforward.

Follow these steps:
1 - Constrain the scroll view itself as you normally would. In this case, constrain the scroll view to it’s parent’s safe area.
2 - Tell the scroll view what size its contents are! Constrain its subviews (in this case, the stack view) to the Content Layout Guide.
3 - Tell the scroll view’s contents what size you actually want them to be! In step one, you effectively set the size of the scroll view’s Frame Layout Guide. So, where you might have had to constrain something inside the scroll view to the safe area or root view of the view controller, you can now constrain it to the scroll view’s Frame Layout Guide. For example, in this episode you’d constrain the image to 25% of the Frame Layout Guide’s height.