iphone - iOS Auto Layout UIView Drawing cycle -


in 1 of wwdc videos, apple said layout done top down, ie superview subview (after constraints calculated bottom up). display done top down.

my questions are: 1. @ point in viewcontroller view's frame (origin , size) determined? tried log size of view (defined using auto layout), 0 0 0 0, odd, because view generated in simulator;

for autoresized view, when view.frame available?

  1. same question, except time uiimageview.frame. tried log console, though size fit constraints, logged uiimageview frame 0 0 width_of_original_image height_of_original_image. other views labels, frame printed correctly on console.

it seems there mysterious auto layout engine performs transform, , nobody knows going on inside engine, check thrown onto simulator display figure out how view rendered engine???

it's not mysterious. it's quite simple! think of constraints instructions written down on pieces of paper - views. every once in while, it's layout time! runtime collects pieces of paper views in order , obeys them - , end laid out frames.

so if check sizes of things before layout time, wrong answer because hasn't happened yet.

and when is layout time? it's whenever runtime sends views layoutsubviews - in fact, runtime obeys constraints , performs layout during layoutsubviews. , view controller can hear before or after, viewwilllayoutsubviews , viewdidlayoutsubviews.

i think part confuses beginners happens when view controller comes existence. viewdidload means has view, all; neither view nor subviews in interface yet, there can no layout. considerably later, viewwillappear:, view goes interface, , now layout. if check sizes in, say, viewdidappear:, right.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -