{"id":9098,"date":"2014-07-09T15:46:28","date_gmt":"2014-07-09T19:46:28","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=9098"},"modified":"2014-07-09T15:46:28","modified_gmt":"2014-07-09T19:46:28","slug":"auto-layout-and-views-that-wrap","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/07\/09\/auto-layout-and-views-that-wrap\/","title":{"rendered":"Auto Layout and Views That Wrap"},"content":{"rendered":"<p><a href=\"http:\/\/devetc.org\/code\/2014\/07\/07\/auto-layout-and-views-that-wrap.html\">Jonathon Mah<\/a>:<\/p>\n<blockquote cite=\"http:\/\/devetc.org\/code\/2014\/07\/07\/auto-layout-and-views-that-wrap.html\"><p>The first call to <code>[super layoutSubviews]<\/code> will evaluate the constraints on the label (since it&rsquo;s a direct subview) and change its frame accordingly.\nAt this point the width is useful, but the height is not; the height was set using the label&rsquo;s intrinsic content size, which in turn relied on a preferred max layout width value that is now stale.<\/p>\n<p>Now we know the actual width of the label, we set that as its max layout width.\nInternally, this causes the label to invalidate its intrinsic content size; when it&rsquo;s next queried, it will have the accurate height for its current width.\nWith all layout information in place, we call <code>[super layoutSubviews]<\/code> again.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Jonathon Mah: The first call to [super layoutSubviews] will evaluate the constraints on the label (since it&rsquo;s a direct subview) and change its frame accordingly. At this point the width is useful, but the height is not; the height was set using the label&rsquo;s intrinsic content size, which in turn relied on a preferred max [&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-9098","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\/9098","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=9098"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9098\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=9098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=9098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=9098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}