User Tools

Site Tools


ios-labs-s14:intermediate-views

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ios-labs-s14:intermediate-views [2014/02/23 21:44] (current)
mbarboi created
Line 1: Line 1:
 +=====View Hierarchy=====
 +All views are organized in a **hierarchy**,​ which can easily be thought of as a tree. All views have a parent view that owns them and may have subviews that they own.
  
 +The root view in any hierarchy is the UIView property of the controller on the screen. All views are ultimately subviews of this view. 
 +
 +Views are placed on the screen based on a property called **frame**. Frame is of type CGRect (a struct, not an Objective-C object-- no asterix when declaring, no objective-c methods) and has four fields:
 +  -x- horizontal displacement from parent'​s origin
 +  -y- vertical displacement from parent'​s origin
 +  -width
 +  -height
 +
 +The origin (the coordinates 0,0) of every view is in the top left corner. Note that views do not orient themselves in the **window'​s** coordinate system, but of their **parent'​s** coordinate system. Subviews of a Controller'​s view property with origin at (100, 100) appear at (100, 100), but subviews of **that** subview at (100, 100) appear at (200, 200) in reference to the view controller'​s origin. ​
 +
 +You cannot edit the frame property of a view by changing its fields, you must set the whole property at once by assigning a new CGRect, using 
 +  CGRectMake(x,​ y, width, height);
 +
 +Views are automatically set as children when dragging in new views in InterfaceBuilder and will appear if their parent appears. When adding a view programmatically by instantiating and setting its frame, you must call [PARENT addSubview:​CHILD] in order to add it to the view hierarchy. ​
ios-labs-s14/intermediate-views.txt ยท Last modified: 2014/02/23 21:44 by mbarboi