mvc

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "mvc"

Transcription

1 Build an application Tutor : Michael Pan

2 Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist -

3 UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication sharedapplication]

4 Delegation - ( ) <UIApplicationDelegate>

5 Delegation - Animation A B Work for awhile A B

6 Delegation - Code A A{ B* delegate; } A -(void) passtob{ [delegate atctionofb]; A * a = [A new] ; B * b = [B new]; a.delegate = b; [a passtob]

7 UIApplicationDelegate - (void)applicationdidreceivememorywarning: (UIApplication *)application; - (void)applicationwillresignactive: (UIApplication *)application; - (BOOL)application:(UIApplication *)application handleopenurl:(nsurl *)url; - (BOOL)application:(UIApplication *)application didfinishlaunchingwithoptions: (NSDictionary *)launchoptions - (void)applicationwillterminate: (UIApplication *)application;

8

9 or

10 Window-based

11

12 Save

13 Xcode

14 <UIApplicationDelegate> UIApplication Project Navigator

15 Main XIB

16 main.m #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retval = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retval; }

17 UIApplicationMain int UIApplicationMain ( int argc, char *argv[], NSString *principalclassname, NSString *delegateclassname ); argc argv main argv main principalclassname UIApplication Class name nil UIApplication delegateclassname application Class name principalclassname UIApplication application-delegate nil main nib ( ios xib MainWindow.xib )

18 MainWindow.xib UIWindow

19 IB - AppDelegate

20 - UIWindow

21

22

23 Model, View, Controller

24 MVC Design Pattern Controller Model View

25 View

26 Model View

27 Controller Model View View Model View

28 Controller CPU Model View Memory, DISK Monitor

29 Interface Builder

30 Xib or Nib files V in MVC model Controller

31 Load nib or xib file Object value / setting IBAction IBOutlet

32 xib Loading controller -awakefromnib -awakefromnib xib connection xib

33 Demo - awakefromnib

34 Target, Action & Event

35 Event-Event Handler View Event target - event handler target action Event Touch Value change Editing

36 Event, Target/Action Event occurs target : myobject action event : MyController { } -(void) Event Handler

37 Action methods (void)actionmethod; // event event - (void)actionmethod:(id)sender; // event event - (void)actionmethod:(id)sender withevent:(uievent *)event // event

38 Example -(void) valuechanged:(id) sender { value = [sender value]; }

39 Multiple target-action Event target action Desktop Cocoa target-action IB

40 @interface UIControl - (void)addtarget:(id)target action:(sel)action forcontrolevents: (UIControlEvents)controlEvents; - (void)removetarget:(id)target action:(sel)action forcontrolevents:

41 UI - Components UIView UIControl UIButton UISlider

42 Target, Action & Event

43 Review - Xcode & Interface Builder

44 Oh! Xcode

45 Xcode Control +

46 Project

47

48

49 Xcode

50 Simulator

51 Xib

52 Oh! Interface Builder

53

54 Inspector & Library Inspector Library

55 Document Window

56 File s Owner

57

58 Command + S : Command

59 Xcode

60

61 Hello iphone App

62 Templates for game 3D Model Basic With Controller and View

63 View-Based Project Project name Source Codes Project Configuration

64 Entry Point ProjectName+AppDelegate.m

65 UI Layout

66 Interface Builder

67 View

68 Build and Go - XCode

69 Console Console

70 Recap

71 String in this is a string not string in c or c++

72 NSLog() printf() %d : %f : : objectiv-c string My name is i am %d years Michael, 5);

73 Set Break Point enable disable

74 Demo Break Point

75 Recap

76 Simulator Simulate Single Finger Tap Drag Two Fingers Zoom in/out (click + alt) Move (click + alt + shift)

77 Simulator - Support 1 command + command + control + command + Z command + L shift + command + H Tap( ) Touch and Hold ( ) Double Tap ( ) Swipe ( ) Flick ( ) click Double Click

78 Simulator - Support 2 Drag Pinch Option Touch shift Pinch Option Core Location Xcode Simulator icon icon icon Home Button Reset Content and Setting Apple 100 System Sound Service AvAudioPlayer MPMoviePlayerController

79 Demo Simulator

80 Questions?