Занятие 2Views и ViewControllers
Кратко• MVC• Views и ViewControllers• Xcode + IB demo• Практика
MVC
MVC
MVC        ControllerModel                View
MVC              Controller        getModel                      View
MVC              Controller        get                setModel                            View
MVC        ControllerModel                View
MVC        Controller          notifyModel                View                     event
MVC                           process              Controller        set                 get                notifyModel   ...
MVC        ControllerModel                View
MVC                             process                Controller               notify   Model                          Vi...
MVC                               process                  Controller           get                 notify   Model        ...
MVC                               process                  Controller           get                   set                 ...
Cocoa• Model – Order, OrderItem, NSArray...• View - UIView• Controller - UIViewController
UIViewUIViewController
UIView                                UIWindow : UIVIew• UIView                           UIView                          ...
UIViewController• Создает View и добавляет его в subview• Имеет доступ к модели• Инициализирует контролы• Получает уведомл...
UIViewController                                   UIWindow : UIVIew     UIViewController                 UIView @property...
UIViewController• viewDidLoad• viewDidUnload• viewDidAppear• viewDidDisappear
UIApplicationDelegate
UIApplicationDelegate• application:didFinishLaunchingWithOptions• applicationWillTerminate• applicationWillResignActive• a...
DEMO
Xcode                   Interface Builder    SimpleViewController              File’s OwnerIBOutlet ... firstNameTextFieldI...
Xcode                           Interface Builder                                 class    SimpleViewController           ...
Xcode                           Interface Builder                                 class    SimpleViewController           ...
Xcode                           Interface Builder                                 class    SimpleViewController           ...
loadView      UIViewController- (UIView)view;- (void)loadView;    SimpleViewControllerIBOutlet ... firstNameTextFieldIBOutl...
loadView                        UIViewController                  - (UIView)view;                  - (void)loadView;      ...
loadView                        UIViewController                  - (UIView)view;                  - (void)loadView;      ...
loadViewПри первом обращении  вызывает loadView                             UIViewController                       - (UIVi...
loadViewПри первом обращении  вызывает loadView                                     Дефолтная реализация                  ...
loadView                        UIViewController                  - (UIView)view;                  - (void)loadView;      ...
loadView                        UIViewController                  - (UIView)view;                  - (void)loadView;      ...
loadView                        UIViewController                  - (UIView)view;                  - (void)loadView;      ...
Кратко• MVC• Views и ViewControllers• Xcode + IB demo
ПрактикаView Controller Programming Guide for iOS• OrderViewController• initWithOrder:(Order *)order;• display first order ...
В следующей серии• TableViewController• NavigationViewContoller
Upcoming SlideShare
Loading in …5
×

занятие 2

635 views
565 views

Published on

Published in: Spiritual, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
635
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • занятие 2

    1. 1. Занятие 2Views и ViewControllers
    2. 2. Кратко• MVC• Views и ViewControllers• Xcode + IB demo• Практика
    3. 3. MVC
    4. 4. MVC
    5. 5. MVC ControllerModel View
    6. 6. MVC Controller getModel View
    7. 7. MVC Controller get setModel View
    8. 8. MVC ControllerModel View
    9. 9. MVC Controller notifyModel View event
    10. 10. MVC process Controller set get notifyModel View event
    11. 11. MVC ControllerModel View
    12. 12. MVC process Controller notify Model Viewmodel change
    13. 13. MVC process Controller get notify Model Viewmodel change
    14. 14. MVC process Controller get set notify Model Viewmodel change
    15. 15. Cocoa• Model – Order, OrderItem, NSArray...• View - UIView• Controller - UIViewController
    16. 16. UIViewUIViewController
    17. 17. UIView UIWindow : UIVIew• UIView UIView UITextField : UIView• subviews, superview UILabel : UIView• UIWindow• Controls - MobileHIG.pdf• ViewPG UIButton : UIView
    18. 18. UIViewController• Создает View и добавляет его в subview• Имеет доступ к модели• Инициализирует контролы• Получает уведомления о событиях view• При обработке может считывать и записывать информацию в контролы
    19. 19. UIViewController UIWindow : UIVIew UIViewController UIView @property ... UIView *view UITextField : UIView UILabel : UIView CustomViewController@property ... UITextField *tt@property ... UILabel *label... (void)actionMethod ... UIButton : UIView Order
    20. 20. UIViewController• viewDidLoad• viewDidUnload• viewDidAppear• viewDidDisappear
    21. 21. UIApplicationDelegate
    22. 22. UIApplicationDelegate• application:didFinishLaunchingWithOptions• applicationWillTerminate• applicationWillResignActive• applicationDidBecomeActive
    23. 23. DEMO
    24. 24. Xcode Interface Builder SimpleViewController File’s OwnerIBOutlet ... firstNameTextFieldIBOutlet ... lastNameTextField View First Name TextField Last Name TextField
    25. 25. Xcode Interface Builder class SimpleViewController File’s OwnerIBOutlet ... firstNameTextFieldIBOutlet ... lastNameTextField View First Name TextField Last Name TextField
    26. 26. Xcode Interface Builder class SimpleViewController File’s OwnerIBOutlet ... firstNameTextField Outlets:IBOutlet ... lastNameTextField firstNameTextField lastNameTextField View First Name TextField Last Name TextField
    27. 27. Xcode Interface Builder class SimpleViewController File’s OwnerIBOutlet ... firstNameTextField Outlets:IBOutlet ... lastNameTextField firstNameTextField lastNameTextField View First Name TextField Last Name TextField
    28. 28. loadView UIViewController- (UIView)view;- (void)loadView; SimpleViewControllerIBOutlet ... firstNameTextFieldIBOutlet ... lastNameTextField
    29. 29. loadView UIViewController - (UIView)view; - (void)loadView; SimpleViewControllerinitWithNibName IBOutlet ... firstNameTextField IBOutlet ... lastNameTextField
    30. 30. loadView UIViewController - (UIView)view; - (void)loadView; SimpleViewControllerinitWithNibName IBOutlet ... firstNameTextField view IBOutlet ... lastNameTextField
    31. 31. loadViewПри первом обращении вызывает loadView UIViewController - (UIView)view; - (void)loadView; SimpleViewControllerinitWithNibName IBOutlet ... firstNameTextField view IBOutlet ... lastNameTextField
    32. 32. loadViewПри первом обращении вызывает loadView Дефолтная реализация UIViewController загружает xib - (UIView)view; - (void)loadView; xib View textField SimpleViewController textFieldinitWithNibName IBOutlet ... firstNameTextField button view IBOutlet ... lastNameTextField
    33. 33. loadView UIViewController - (UIView)view; - (void)loadView; SimpleViewControllerinitWithNibName view
    34. 34. loadView UIViewController - (UIView)view; - (void)loadView; SimpleViewControllerinitWithNibName view
    35. 35. loadView UIViewController - (UIView)view; - (void)loadView; Переопределив loadView можно SimpleViewController создать view программноinitWithNibName - (void)loadView; view
    36. 36. Кратко• MVC• Views и ViewControllers• Xcode + IB demo
    37. 37. ПрактикаView Controller Programming Guide for iOS• OrderViewController• initWithOrder:(Order *)order;• display first order item• update button• textResultLabel = [order description];
    38. 38. В следующей серии• TableViewController• NavigationViewContoller

    ×