Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

whitedragon101

macrumors 65816
Original poster
Sep 11, 2008
1,349
339
Here is what I have done.

I have a standard viewController in the storyboard set to 3.5inch display. Then i drag in a view make it the full size of the screen and set its colour to blue. I drag in a button to the view and set a single constraint
- bottom space to bottom layout guide = 20

I run this in the simulator using a 4 inch screen and the view has automatically expanded to fit the whole size and the button has moved to the bottom of the larger screen with it . Great.

Now I add a scrollview I set the it to pin top and bottom. I create a button and place it at the bottom of the scrollview and set it to pin bottom (the bottom constraint distance). When I run it the scrollview scales and increases in size to fit the 4 inch screen BUT the button stays where it is.

Any ideas how I can get the bottom to stay pinned to the bottom of the scrollview as it scales?
 
Last edited:
I believe I saw this in one of the WWDC videos on using AutoLayout (can't remember which session or year) but you should make a separate view to be the contents of your scroll view, layout everything you want in it, and then at runtime load that separate view into your scroll view.
 
I'm not using the auto layout function, cus somehow its not working great.
Some video tutorials shown the great part of it, however I'm still not getting it.
With a load workarounds with adding constraints and stuff, I turn off auto-layout.

In the storyboard, go to File Inspector, and turn of 'Use Autolayout'.
Then for each object you have, i.e. an button you want to stick at the bottom, no matter how big the screen is, go to the size inspector and you will see your having an extra option for 'Autosizing'. For here you can chose if it should be scaling along the width or height, and the pin positions, top, left, right and bottom.

Just uncheck the top pin, and check the bottom.

And for example you are showing an imageview, which is a bit out of the top, bottom and sides. And you want it to scale with the screens, but keep the offsets, click all pins and click both scaling options. :)

Its great!

That's all for it for now. It helped me alot and made me got rid of loads warnings about constraints missing and stuff..

cheers!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.