Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm looking for an example xCode project that can demonstrate how to apply autolayouts to UIViews programmatically. I see quite a lot of questions that deal with how to apply autolayout, but I'm a total novice and need something to play with before I can get a feeling for how autolayouts work.

Thank you!

share|improve this question
I don't know of any example projects, but I would suggest watching the 3 videos on the subject from WWDC 2012 ("Introduction to Auto Layout for iOS and OS X", "Best Practices for Mastering Auto Layout", and "Auto Layout by Example". They discuss both IB and code approaches in these videos. – rdelmar Apr 6 at 15:52

1 Answer

Take a look at this: http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2 (with IB) and this: http://www.techotopia.com/index.php/Implementing_iOS_6_Auto_Layout_Constraints_in_Code (without IB)

In addition: If you want to do it programmatically I would prefer to use math instead of complex AutoLayout statements. If you want to have a button placed 20pixel up from bottom just work with something like [[[[UIScreen mainscreen]bounds]size]height]-20] I think this is easier to work with.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.