Head first iOS programming
Transcript of Head first iOS programming
Head First iOS [email protected]
View• What’s View
• rectangle area on screen
• draw content
• handle events
• every view has one super-view
• every view has zero or more subviews
View• Utility Classes
• CGPoint
• location in space: {x, y}
• CGSize
• dimensions: {width, height}
• CFRect
• location and dimension: {origin, size}
View• UIView coordinate
• View’s location and size expressed in two ways• Frame is in superview’s coordinate system• Bounds is in local coordinate system
View• Create and Add View
• Add/remove views in IB or using UIView methods
- (void)addSubview:(UIView *)view;- (void)removeFromSuperview;
• Manipulate the view hierarchy manually- (void)insertSubview:(UIView *)view atIndex:(int)index;- (void)insertSubview:(UIView *)view belowSubview:(UIView
*)view;- (void)insertSubview:(UIView *)view aboveSubview:(UIView
*)view;- (void)exchangeSubviewAtIndex:(int)index
withSubviewAtIndex:(int)otherIndex;
View• Examples
• Creating a view. and positioning a view in superview
• Drawing a view
• Handing events
• Creating view with Interface Builder
View• Common Views
• UILabel, UIButton
• UITextField, UITextView
• Clear Button, Keyboard, ReturnKey, Secure
• Editable
• UITableView
ViewController• UIViewController
• Provides the fundamental view management model for all iOS apps
• A View Controller manages a set of views
ViewController• UIViewController
• viewDidLoad
• viewWillAppear / viewDidAppear
• viewWillDisappear / ViewDidDisappear