Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage Autolayout constraints which can be applicable for iOS 7 & iOS 6.0 both

Tags:

ios

ios7

ios6

I have created the new iOS project in xCode 5 with deployment target 6.0 and Apply Pin constraint [Bottom space to superview] to make AutoLayout applicable for iOS 7 as well iOS 6.0 with different devices but

When I choose option "View as : " : iOS 7.0 & later Button looks like following

enter image description here

then When I change option "View as : " : iOS 6.0 & earlier the button looks like following

enter image description here

How Do I manage constrait such a way that make applicable with iOS 6.0 & iOS 7.0 both ?

Thanks in advance !!

like image 600
imDeveloper Avatar asked Sep 13 '13 12:09

imDeveloper


People also ask

What are constraints in iOS?

Most constraints define a relationship between two items in our user interface. These items can represent either views or layout guides. Constraints can also define the relationship between two different attributes of a single item, for example, setting an aspect ratio between an item's height and width.

What is iOS Autolayout?

Auto Layout is the preferred technology to define layouts for user interfaces on iOS and macOS. Its goal: To make it easy for you to create user interfaces that adapt automatically to different screen sizes and orientations.

How do you add constraints in storyboard iOS?

Open the Align menu with the yellow button selected and check Horizontally in Container, then click Add 1 Constraint. Now, select both buttons at the same time using the Shift key and, in the Align menu, check Leading Edges. Again, actually install the constraint by clicking Add 1 Constraint.

What is constraint to margin in iOS?

Basically if the layout margins are 8,8,8,8 (the default), a constraint with 0 leading space to container margin will have an x position of 8. Note that this is only available on iOS8 or later.


1 Answers

I had a similar issue in my story board, I searched a lot with no hope and ended up removing all constrains by:

Editor -> Resolve Auto-Layout Issues -> Clear all constraints in view controller

Then reordering again, this solved most of my issues.

First from Apple Transition Guide:

If business reasons require you to continue supporting iOS 6 or earlier, you need to choose the most practical way to update the app for iOS 7. The techniques you choose can differ, but the overall advice remains the same: First, focus on redesigning the app for iOS 7. Then, bring the changes to the iOS 6 version as appropriate.

This means that you could face some issues in prior iOS versions, especially in layout and you need to re-layout your controls under iOS7 then test them under iOS6.

like image 110
Tarek Hallak Avatar answered Oct 05 '22 23:10

Tarek Hallak