# Demystifying iOS Layout

DevFeed: [Demystifying iOS Layout](<https://devfeed.tech/articles/demystifying-ios-layout-19829.md>)

Original publisher: [Read original article](<https://tech.gc.com/demystifying-ios-layout/>)

Author: GameChanger

Published: 2017-04-23T02:34:57Z

Content type: article

Language: en

Sources: [GameChanger](<https://devfeed.tech/sources/gamechanger.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [App](<https://devfeed.tech/topics/app.md>), [debug](<https://devfeed.tech/topics/debug.md>), [ui](<https://devfeed.tech/topics/ui.md>)

Tags: [app](<https://devfeed.tech/tags/app.md>), [applications](<https://devfeed.tech/tags/applications.md>), [blog-post](<https://devfeed.tech/tags/blog-post.md>), [debug](<https://devfeed.tech/tags/debug.md>), [ios](<https://devfeed.tech/tags/ios.md>), [ui](<https://devfeed.tech/tags/ui.md>)

## AI overview

This article explains how iOS view layout and content updates relate to the application's main run loop. It describes event handling, the update cycle, and the timing of layout, display, and constraint changes, helping developers understand and debug view-update behavior.

## Source excerpt

Some of the most difficult issues to avoid or debug when you first start building iOS applications are those dealing with view layout and content. Often, these issues happen because of misconceptions about when view updates actually occur. Understanding how and when a view updates requires a deeper understanding of the main run loop of an iOS application and how it relates to some of the methods provided by UIView. This blog post will explain these interactions, hopefully clarifying how to use use UIView's methods to get the behavior you want. Main run loop of an iOS app The main run loop of an iOS application is what handles all user input events and triggers the appropriate responses in your application. Any user interaction with the application is added to an event queue. The application object, shown in the diagram below, takes events off the queue and dispatches them to the other objects in the application. It essentially executes the run loop by interpreting input events from the user and calling the corresponding handlers for that input in the application's core objects. These handlers call code written by application developers. Once these method calls return, control returns to the main run loop and the update cycle begins. The update cycle is responsible for laying out and redrawing views (described in the next section). Below is an illustration of how the application communicates with the device and processes user input. https://developer.apple.com/library/content/documentation/General/Conceptual/Devpedia-CocoaApp/MainEventLoop.html Update cycle The update cycle is the point at which control returns to the main run loop after the app finishes running all your event handling code. It's at this point that the system begins updating layout, display, and constraints. If you request a change in a view while it is processing event handlers, the system will mark the view as needing a redraw. At the next update cycle, the system will execute all changes on these