head first ios programming

20
Head First iOS Programming Ted [email protected]

Upload: tedzhaoxa

Post on 11-Apr-2017

455 views

Category:

Internet


2 download

TRANSCRIPT

Head First iOS [email protected]

Agenda• Prerequisites

• MVC

• View

• ViewController

Prerequisites• Mac(MacBook, Mac mini, iMac)

• Apple Developer / iOS Developer Program

• Xcode

MVC• Design pattern

• Model

• View

• Controller

MVC• Design pattern

• Model

• View

• Controller

MVC• MVC in iOS View

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• UIWindow

• contains the entire view hierarchy• one UIWindow for an iPhone app

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• UIView coordinate

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 with View

• IBOutlet

• IBAction

ViewController• Create UIViewController

• xib

• code

ViewController• UIViewController

• viewDidLoad

• viewWillAppear / viewDidAppear

• viewWillDisappear / ViewDidDisappear

ViewController• Examples

Questions• ?