Often when working with AutoLayout programmatically something can go wrong. Constraints that you created just not work or program fails. There are most popular mistakes that can happen
1. Forgot to addSubView method
You simply forgot to add your view as subview to parent view.
2. Forgot to set translatesAutoresizingMaskIntoConstraints property to false
Another important thing to remember. You need to enable AutoLayot for your view. So, if you forgot to set translatesAutoresizingMaskIntoConstraints to false then your view will not using AutoLayout.
3. Forgot to activate constraint
When you create new constraint it is not enough to make it work. You have to activate it.
4. Your views in different hierarchies
You can only add constraint to views that are in the same hierarchy. In other words - constraint for your view must operate with parent view (or view from the same hierarchy).
5. You must specify position and size both. Directly or indirectly
When you create constraints you need to specify size and position for your view. In other case your constraints will not work.
Directly specifying example (setup center position and width and height)
Indirectly specifying example (setup top, bottom, leading and width)
You wrote an amazing article. I am amazed, your efforts are showing in the article. I hope in future I will see more Articles from you.
ReplyDelete-Custom Website Design
This article impresses me with its well-researched material and good writing. I couldn't put this book down since I was so engrossed in it. Your work and skill have impressed me. Thank you a lot. It can be beneficial to those who want to learn more about Best Custom Websites
ReplyDeleteThank you for writing this quality informational content.Your writing technique is impressive and enjoyable to read. I'll come back for more fantastic material.
ReplyDeleteBest wishes, and good luck.
Custom Build Website
This is a great article! Thank you very much. I really need these suggestions. An in-depth explanation is of great benefit. Incredibly inspiring to see how you write. Custom Website
ReplyDeleteAmazing write-up! The blog was very informative. Keep it up!
ReplyDeleteSoftware Testing Services
Amazing write-up! The blog was very informative. Keep it up!
ReplyDeleteCustom Website/a>