Top Banner
Head First iOS Programming Ted [email protected]
20

Head first iOS programming

Apr 11, 2017

Download

Internet

tedzhaoxa
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Head first iOS programming

Head First iOS [email protected]

Page 2: Head first iOS programming

Agenda• Prerequisites

• MVC

• View

• ViewController

Page 3: Head first iOS programming

Prerequisites• Mac(MacBook, Mac mini, iMac)

• Apple Developer / iOS Developer Program

• Xcode

Page 4: Head first iOS programming

MVC• Design pattern

• Model

• View

• Controller

Page 5: Head first iOS programming

MVC• Design pattern

• Model

• View

• Controller

Page 6: Head first iOS programming

MVC• MVC in iOS View

Page 7: Head first iOS programming

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

Page 8: Head first iOS programming

View• UIWindow

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

Page 9: Head first iOS programming

View• Utility Classes

• CGPoint

• location in space: {x, y}

• CGSize

• dimensions: {width, height}

• CFRect

• location and dimension: {origin, size}

Page 10: Head first iOS programming

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

Page 11: Head first iOS programming

View• UIView coordinate

Page 12: Head first iOS programming

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;

Page 13: Head first iOS programming

View• Examples

• Creating a view. and positioning a view in superview

• Drawing a view

• Handing events

• Creating view with Interface Builder

Page 14: Head first iOS programming

View• Common Views

• UILabel, UIButton

• UITextField, UITextView

• Clear Button, Keyboard, ReturnKey, Secure

• Editable

• UITableView

Page 15: Head first iOS programming

ViewController• UIViewController

• Provides the fundamental view management model for all iOS apps

• A View Controller manages a set of views

Page 16: Head first iOS programming

ViewController• UIViewController with View

• IBOutlet

• IBAction

Page 17: Head first iOS programming

ViewController• Create UIViewController

• xib

• code

Page 18: Head first iOS programming

ViewController• UIViewController

• viewDidLoad

• viewWillAppear / viewDidAppear

• viewWillDisappear / ViewDidDisappear

Page 19: Head first iOS programming

ViewController• Examples

Page 20: Head first iOS programming

Questions• ?