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

macone123

macrumors newbie
Original poster
May 5, 2015
3
0
Question regarding auto layout.

I have my labels/buttons/images in the center of the iphone storyboard. Everything looks great in the iPhone 6 and iphone 6 plus. Only issue is when I have the simulator open in iphone 5s or iphone 5, the labels/buttons/images won't center on the screen.. The right side of the image/labels are cut off due to the screen being obviously smaller. Auto layout is on.

I tried adding constraints, everything looks fine in iphone 6 and plus, but the iphone 5 is giving me an issue. When I center with constraints the iphone 5 simulator deletes some of my buttons or they don't look correct, or still are not centered the middle of the screen. I tried adding a lead constraint and following constraint, still without any resolvement.

I was just wondering if anyone know of a tip to make this work a little better?
 
There is no easy tip to make this work. You will have to learn through trial and error how to set the constraints for the layouts. Some of them fix a position to a spot, some attached them to other objects and some are relative to the screen borders.

Keep adjusting and eventually it will work out.
 
iPhone 5

Formatting seems to be fine in iphone 6 and iphone 6 plus. Main issue is the iPhone 5/5s.... Every constraint i use seems to somehow delete the option from the screen.

I'll keep messing around with it.

Much thanks.
 
Mac...

I found constraints difficult to master, especially when you click on the add "suggested" ones. These often, quite often, do not work on all the devices because of the differences in screen sizes.

What I recommend you do if you can't work it out is design for a single phone, like the 5, and then test the view on a larger device to see how things move. You will also have to do a lot of simulated device rotation to see how it looks in both landscape and portrait views.

It a hassle to make a universal app, but in the end worth it.
 
Autolayout

So it looks like it is possible to use:

Code:
        main.center = CGPointMake(20, 200);

When Autolayout is turned off, you can move the the UILabel to the correct positioning, but I was wondering if anyone had any other ideas to do this without completely turning off all of Autolayout for the whole project?

Is there a way to disable it for one screen anyone knows of so I will be able to set the position of labels?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.