{"id":8508,"date":"2014-03-04T15:13:31","date_gmt":"2014-03-04T20:13:31","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=8508"},"modified":"2014-03-04T15:13:31","modified_gmt":"2014-03-04T20:13:31","slug":"how-i-learned-to-stop-worrying-and-love-cocoa-auto-layout","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/03\/04\/how-i-learned-to-stop-worrying-and-love-cocoa-auto-layout\/","title":{"rendered":"How I Learned to Stop Worrying and Love Cocoa Auto Layout"},"content":{"rendered":"<p><a href=\"http:\/\/oleb.net\/blog\/2014\/03\/how-i-learned-to-stop-worrying-and-love-auto-layout\/\">Ole Begemann<\/a>:<\/p>\n<blockquote cite=\"http:\/\/oleb.net\/blog\/2014\/03\/how-i-learned-to-stop-worrying-and-love-auto-layout\/\"><p>If you find yourself in a situation that is difficult to solve with Auto Layout, just don&rsquo;t use it for that particular view. You can freely mix the constraint-based layout with manual layout code, even within the same view hierarchy.<\/p>\n<p>[&#8230;]<\/p>\n<p>You can think of Auto Layout as just an additional step that runs automatically in your view&rsquo;s <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/uikit\/reference\/uiview_class\/UIView\/UIView.html#\/\/apple_ref\/doc\/uid\/TP40006816-CH3-SW27\"><code>layoutSubviews<\/code><\/a> method. The Auto Layout algorith performs some magic, at the end of which your subviews&rsquo; frames are set correctly according to the layout constraints. When that step is done, the Auto Layout engine halts until a relayout is required (for example, because the parent view size changes or a constraint gets added). What you do to your subviews&rsquo; frames after Auto Layout has done its job, doesn&rsquo;t matter.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Ole Begemann: If you find yourself in a situation that is difficult to solve with Auto Layout, just don&rsquo;t use it for that particular view. You can freely mix the constraint-based layout with manual layout code, even within the same view hierarchy. [&#8230;] You can think of Auto Layout as just an additional step that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[200,69,31,30,71],"class_list":["post-8508","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-autolayout","tag-cocoa","tag-ios","tag-mac","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8508","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=8508"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8508\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=8508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=8508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=8508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}