{"id":1789,"date":"2013-09-13T12:41:30","date_gmt":"2013-09-13T08:41:30","guid":{"rendered":"https:\/\/blog.alwawee.ru\/?p=1789"},"modified":"2013-09-13T12:48:28","modified_gmt":"2013-09-13T08:48:28","slug":"ios-autolayout-notes","status":"publish","type":"post","link":"https:\/\/blog.alwawee.ru\/?p=1789","title":{"rendered":"iOS AutoLayout Notes"},"content":{"rendered":"<p>To transition the application to support iOS 7, Apple recommends to use Auto Layout extensively in their <a title=\"https:\/\/developer.apple.com\/library\/prerelease\/ios\/design\/index.html#\/\/apple_ref\/doc\/uid\/TP40013289\" href=\"https:\/\/developer.apple.com\/library\/prerelease\/ios\/design\/index.html#\/\/apple_ref\/doc\/uid\/TP40013289\" target=\"_blank\">iOS 7 Transition Guide<\/a>.<\/p>\n<p>Also at the recent time after about one year of creating intefaces completely programmatically, I again returned to using xibs to create TableViewCell layouts and other layouts rapidly. And now I definetely need to learn AutoLayout.<\/p>\n<p>So I decided to learn the features of AutoLayout from <a title=\"https:\/\/developer.apple.com\/library\/prerelease\/ios\/documentation\/UserExperience\/Conceptual\/AutolayoutPG\/Introduction\/Introduction.html#\/\/apple_ref\/doc\/uid\/TP40010853-CH13-SW1\" href=\"https:\/\/developer.apple.com\/library\/prerelease\/ios\/documentation\/UserExperience\/Conceptual\/AutolayoutPG\/Introduction\/Introduction.html#\/\/apple_ref\/doc\/uid\/TP40010853-CH13-SW1\" target=\"_blank\">Auto Layout Guide<\/a> and here I&#8217;m going to post some notes, that I took for myself to remember what to do and remember features of AutoLayout.<\/p>\n<p>Auto Layout is a system that lets you lay out your app\u2019s user interface by creating a mathematical description of the relationships between the elements.<\/p>\n<p>The fundamental building block in Auto Layout is the\u00a0<strong>constraint<\/strong>. Constraints express rules for the layout of elements in your interface; for example, you can create a constraint that specifies an element\u2019s width, or its horizontal distance from another element.<\/p>\n<p>Constraints are cumulative, and do not override each other.<\/p>\n<p>Rather than writing an omniscient controller that calculates where views need to go for a given geometry, views become more self-organizing. This approach reduces the complexity of controller logic, and makes it easier to redesign views without requiring corresponding changes to the layout code.<\/p>\n<p>Leaf-level views such as buttons typically know more about what size they should be than does the code that is positioning them. This is communicated through the\u00a0intrinsic content size, which tells the layout system that a view contains some content that it doesn\u2019t natively understand, and indicates how large that content is, intrinsically.<\/p>\n<p>The easiest way to add, edit, or remove constraints is to use the visual layout tools in Interface Builder. Creating a constraint is as simple as Control-dragging between two views, or to add multiple constraints at once, you simply use the various pop-up windows.<\/p>\n<p>You can also add constraints using the\u00a0<strong>Auto Layout menu<\/strong>, which resides on the Interface Builder canvas.<\/p>\n<p><strong>Align.<\/strong>\u00a0Create alignment constraints, such as centering a view in its container, or aligning the left edges of two views.<\/p>\n<p><strong>Pin.<\/strong>\u00a0Create spacing constraints, such as defining the height of a view, or specifying its horizontal distance from another view.<\/p>\n<p><strong>Issues.<\/strong>\u00a0Resolve layout issues by adding or resetting constraints based on suggestions.<\/p>\n<p><strong>Resizing.<\/strong>\u00a0Specify how resizing affects constraints.<\/p>\n<p>If you need to add a large set of constraints to describe your interface layout and you don\u2019t want to add constraints one at a time, choose Issues &gt; Add Missing Constraints to add a nonambiguous set of constraints.<\/p>\n<p>If you need to revert to a set of constraints without errors, or you just want to start over, choose Issues &gt; Reset to Suggested Constraints to remove erroneous constraints and add a nonambiguous set of constraints.<\/p>\n<p>Here is a <a title=\"https:\/\/developer.apple.com\/library\/prerelease\/ios\/documentation\/UserExperience\/Conceptual\/AutolayoutPG\/AutoLayoutinCode\/AutoLayoutinCode.html\" href=\"https:\/\/developer.apple.com\/library\/prerelease\/ios\/documentation\/UserExperience\/Conceptual\/AutolayoutPG\/AutoLayoutinCode\/AutoLayoutinCode.html\" target=\"_blank\">link<\/a> on how to work with AutoLayout programmatically. I don&#8217;t need it yet, but it seems to be as easy, as using Interface Builder for this task.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To transition the application to support iOS 7, Apple recommends to use Auto Layout extensively in their iOS 7 Transition Guide. Also at the recent time after about one year of creating intefaces completely programmatically, I again returned to using xibs to create TableViewCell layouts and other layouts rapidly. And now I definetely need to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1789","post","type-post","status-publish","format-standard","hentry","category-ios"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>iOS AutoLayout Notes - Denis Kutlubaev<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.alwawee.ru\/?p=1789\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"iOS AutoLayout Notes - Denis Kutlubaev\" \/>\n<meta property=\"og:description\" content=\"To transition the application to support iOS 7, Apple recommends to use Auto Layout extensively in their iOS 7 Transition Guide. Also at the recent time after about one year of creating intefaces completely programmatically, I again returned to using xibs to create TableViewCell layouts and other layouts rapidly. And now I definetely need to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.alwawee.ru\/?p=1789\" \/>\n<meta property=\"og:site_name\" content=\"Denis Kutlubaev\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/alwaweemobile\" \/>\n<meta property=\"article:published_time\" content=\"2013-09-13T08:41:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-09-13T08:48:28+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/blog.alwawee.com\/?attachment_id=1982\" \/>\n<meta name=\"author\" content=\"Denis Kutlubaev\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Denis Kutlubaev\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=1789#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=1789\"},\"author\":{\"name\":\"Denis Kutlubaev\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#\\\/schema\\\/person\\\/58f1f1f57155b48afab83ba53b3e26a7\"},\"headline\":\"iOS AutoLayout Notes\",\"datePublished\":\"2013-09-13T08:41:30+00:00\",\"dateModified\":\"2013-09-13T08:48:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=1789\"},\"wordCount\":497,\"commentCount\":0,\"articleSection\":[\"iOS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.alwawee.ru\\\/?p=1789#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=1789\",\"url\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=1789\",\"name\":\"iOS AutoLayout Notes - Denis Kutlubaev\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#website\"},\"datePublished\":\"2013-09-13T08:41:30+00:00\",\"dateModified\":\"2013-09-13T08:48:28+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#\\\/schema\\\/person\\\/58f1f1f57155b48afab83ba53b3e26a7\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=1789#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.alwawee.ru\\\/?p=1789\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=1789#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blog.alwawee.ru\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"iOS AutoLayout Notes\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#website\",\"url\":\"https:\\\/\\\/blog.alwawee.ru\\\/\",\"name\":\"Denis Kutlubaev\",\"description\":\"iOS Development\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blog.alwawee.ru\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#\\\/schema\\\/person\\\/58f1f1f57155b48afab83ba53b3e26a7\",\"name\":\"Denis Kutlubaev\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg\",\"caption\":\"Denis Kutlubaev\"},\"description\":\"iOS Developer, creator of Tornado Browser and many other popular apps\",\"sameAs\":[\"http:\\\/\\\/dennis.alwawee.com\"],\"url\":\"https:\\\/\\\/blog.alwawee.ru\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"iOS AutoLayout Notes - Denis Kutlubaev","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.alwawee.ru\/?p=1789","og_locale":"en_US","og_type":"article","og_title":"iOS AutoLayout Notes - Denis Kutlubaev","og_description":"To transition the application to support iOS 7, Apple recommends to use Auto Layout extensively in their iOS 7 Transition Guide. Also at the recent time after about one year of creating intefaces completely programmatically, I again returned to using xibs to create TableViewCell layouts and other layouts rapidly. And now I definetely need to [&hellip;]","og_url":"https:\/\/blog.alwawee.ru\/?p=1789","og_site_name":"Denis Kutlubaev","article_publisher":"https:\/\/www.facebook.com\/alwaweemobile","article_published_time":"2013-09-13T08:41:30+00:00","article_modified_time":"2013-09-13T08:48:28+00:00","og_image":[{"url":"http:\/\/blog.alwawee.com\/?attachment_id=1982","type":"","width":"","height":""}],"author":"Denis Kutlubaev","twitter_misc":{"Written by":"Denis Kutlubaev","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.alwawee.ru\/?p=1789#article","isPartOf":{"@id":"https:\/\/blog.alwawee.ru\/?p=1789"},"author":{"name":"Denis Kutlubaev","@id":"https:\/\/blog.alwawee.ru\/#\/schema\/person\/58f1f1f57155b48afab83ba53b3e26a7"},"headline":"iOS AutoLayout Notes","datePublished":"2013-09-13T08:41:30+00:00","dateModified":"2013-09-13T08:48:28+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.alwawee.ru\/?p=1789"},"wordCount":497,"commentCount":0,"articleSection":["iOS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.alwawee.ru\/?p=1789#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.alwawee.ru\/?p=1789","url":"https:\/\/blog.alwawee.ru\/?p=1789","name":"iOS AutoLayout Notes - Denis Kutlubaev","isPartOf":{"@id":"https:\/\/blog.alwawee.ru\/#website"},"datePublished":"2013-09-13T08:41:30+00:00","dateModified":"2013-09-13T08:48:28+00:00","author":{"@id":"https:\/\/blog.alwawee.ru\/#\/schema\/person\/58f1f1f57155b48afab83ba53b3e26a7"},"breadcrumb":{"@id":"https:\/\/blog.alwawee.ru\/?p=1789#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.alwawee.ru\/?p=1789"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.alwawee.ru\/?p=1789#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.alwawee.ru\/"},{"@type":"ListItem","position":2,"name":"iOS AutoLayout Notes"}]},{"@type":"WebSite","@id":"https:\/\/blog.alwawee.ru\/#website","url":"https:\/\/blog.alwawee.ru\/","name":"Denis Kutlubaev","description":"iOS Development","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.alwawee.ru\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.alwawee.ru\/#\/schema\/person\/58f1f1f57155b48afab83ba53b3e26a7","name":"Denis Kutlubaev","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg","caption":"Denis Kutlubaev"},"description":"iOS Developer, creator of Tornado Browser and many other popular apps","sameAs":["http:\/\/dennis.alwawee.com"],"url":"https:\/\/blog.alwawee.ru\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/posts\/1789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1789"}],"version-history":[{"count":0,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/posts\/1789\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}