How to programmatically disable the automatic layout of iOS 7

I already know that we can disable it by unchecking the File Inspector> Document Builder Document> Use Auto Layout checkbox when we use the interface constructor.

But in my case, I do not use the interface designer or storyboard, only programmatically created views. Then, how to disable auto-layout for iOS 7 using Xcode 5?

How to disable auto-layout for presentation from code? tells us that the automatic layout is disabled if we do not create any restrictions for any kind. I am not sure how to create restrictions, so I do not make mistakes that lead to the inclusion of automatic layout. I want the automatic layout to be turned off.

+4
source share
2 answers

So this answer was deleted by Andrew Barber, but its solid work around, and it is useful, so I am posting it again:

1) DO NOT have views or components laid out in the interface constructor.

2) Add your views purely programmatically, starting with alloc / init and adjusting their frames accordingly.

3) Done.

Hope this helps!

ps. You can also experiment with the limitations of taking views off with:

[view removeConstraints: view.constraints] but I was more fortunate to use clean code.

+7
source

UIView, . . , , :

[view removeConstraints:view.constraints]
+9

All Articles