Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

занятие 2

731 views

Published on

Published in: Spiritual, Technology, Business
  • Be the first to comment

  • Be the first to like this

занятие 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

×