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

Zeppin

macrumors newbie
Original poster
Jan 29, 2014
4
0
I'm currently working on an iPhone app for a local non-profit that I'd like to have be at least reasonably compatible with the iPhone 6 upon release. As this is my first mobile app I'm obviously new to Auto Layout and experiencing some issues with making use of it.

At the top of several of the Views in the app I have a header made from an Image View that's nested inside of a colored sub-view. I've used Auto Layout to ensure that the image view will always have the same distance from the edges of the sub-view and it seems happy with that - blue lines all around in the Storyboard. I'd like the image to maintain its aspect ratio, however, as it looks quite peculiar when that changes, so I've set a constraint on the image view to maintain its aspect ratio. This causes the image view to resize itself to its native resolution, which is huge and totally inappropriate for a 3.5- or 4-inch screen. Introducing a concrete width or height constraint fixes this problem but means that the image will never resize, as one of its dimensions is locked along with its aspect ratio.

How on Earth would one go about ensuring that the image can be resized with the screen while maintaining its aspect ratio? I appreciate any insights that anyone can offer.
 
I really dislike the auto-layout part.
It's too messy and much work. I find it easier to turn off the auto-layout and you will be able to determine your constraints and scaling part just with a click at the 'Size inspector' tab.

for example I made a view, 10 from top, 10 from left and 10 from right.
I want it to stay like that, then I use the auto-sizing for top, left and right, and put the horizontal arrow in there to scale it in width when needed.

IE. change of orientation.

I find this a lot easier that using the auto-layout part, but that might just be a lack of 'interest' to really start learning to use it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.