занятие6

977 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
977
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
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
  • занятие6

    1. 1. Разработка приложений для iPhone и iPad занятие #6
    2. 2. домашнее задание • Шулюгин Владислав - 12 • Кабир Павел - 10 • Николенко Анастасия - 9 • Михаил Терентьев - 12 • Андрей Кузьминов - 9 • Николай Яковлев - 9 • Михаил Акулов - 15 • Павел Мусатов - 12
    3. 3. счет команд• Букукаб = 9 + 6 = 15• l-dendrology = 12 + 15 + 10 + 10 = 47• iTeam = 12 + 9 + 12 + 10 = 43• HPNG = 9 + 8 = 17• Васёк&Эдуард = 8
    4. 4. View-based application Жизненный цикл ViewController- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle - (void)viewDidLoad - (void)viewWillAppear:(BOOL)animated- (void)viewWillDisappear:(BOOL)animated [[NSUserDefaults standartUserDefaults] setFloat: ForKey:]; [[NSUserDefaults standartUserDefaults] floatForKey:]; [[NSUserDefaults standartUserDefaults] synchonize];
    5. 5. вращение- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation{ return (interfaceOrientation == UIInterfaceOrientationPortrait);}- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation{ return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);}
    6. 6. как изменять позиции при вращении?ur View with Interface BuilderInterface Builderw controller class letollerName:bundle:
    7. 7. UINavigationController UINavigationController UINavigationController • Stack of view controllers • Stack of • Navigation bar view controllers • Navigation bar View Controller View Controller Navigation View Controller Navigation Controller View Controller Controller View Controller View Controller Thursday, January 28, 2010 5Thursday, January 28, 2010 5
    8. 8. управление набором ViewController - (void)pushViewController:(UIViewController *)viewControlleranimated:(BOOL)animated;!!!вызывается retain- (UIViewController *)popViewControllerAnimated:(BOOL)animated;pop обычно не вызывается, автоматически при нажатии ‘<-’
    9. 9. первый ViewController- (void)applicationDidFinishLaunching} navController = [[UINavigationController alloc] init]; [navController pushViewController:firstViewController animated:NO]; [window addSubview:navController.view];}
    10. 10. а как использовать?- (void)someAction:(id)sender {} UIViewController *viewController = ...; [self.navigationController pushViewController:viewControlle animated:YES];}
    11. 11. посмотрим?•New Window-Based app•Новый ViewController с кнопкой•NavigationController и FirstViewController в AppDelegate•SecondViewController•Cвойство title у ViewController
    12. 12. как связать всеViewController?
    13. 13. как связать все ViewController?• Не стоит использовать глобальные переменные или AppDelagate• Что нужно на входе следующему ViewController?
    14. 14. как связать все ViewController? Best Practices for Data Flow• Не стоит использовать глобальные • Figure out exactly what needs to be communicated переменные или AppDelagate • Define input parameters for your view controller• Что нужно на входе следующему ViewController? Data List Detail Controller Controller Thursday, January 28, 2010 16
    15. 15. как связать все ViewController? Best Practices for Data Flow• Не стоит использовать глобальные • Figure out exactly what needs to be communicated переменные или AppDelagate • Define input parameters for your view controller• Что нужно на входе следующему ViewController? Data List Detail Controller Controller• В обратную сторону - используя делегаты (с помощью протоколов) Thursday, January 28, 2010 16
    16. 16. Customizing Navigation бонусы к навигации • Buttons or custom controls • Interact with the entire screenThursday, January 28, 2010 20
    17. 17. UINavigationTitle• Содержится у любогоOwnership Navigation Item ViewController Left Bar Button Item View Controller Navigation Item Title View Right Bar Button Item
    18. 18. кнопки справа и слева• UIBarButtonItem отображается сверху• Отображает строку, изображение• Target + Action (как и во всех кнопках)
    19. 19. создание UIBarButtonItem - (void)viewDidLoad { UIBarButtonItem *fooButton = [[UIBarButtonItem alloc] initWithTitle:@"Foo”Text Bar Button Item style:UIBarButtonItemStyleBordered target:self action:@selector(foo:)]; self.navigationItem.leftBarButtonItem = fooButton; [fooButton release]; - (void)viewDidLoad { } UIBarButtonItem *fooButton = [[UIBarButtonItem alloc] - (void)viewDidLoad { initWithTitle:@"Foo”System Bar Button Item UIBarButtonItem *addButton = [[UIBarButtonItem alloc] style:UIBarButtonItemStyleBordered initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self style:UIBarButtonItemStyleBordered action:@selector(foo:)]; target:self action:@selector(add:)]; self.navigationItem.leftBarButtonItem = fooButton; [fooButton release]; self.navigationItem.rightBarButtonItem = addButton; - (void)viewDidLoad [addButton release]; } { } UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
    20. 20. кнопка редактированияEdit/Done Button •• Very common pattern практика реализованная• Every view controller has one available ! Target/action already set upself.navigationItem.leftBarButtonItem = self.editButtonItem; self.navigationItem.leftBarButtonItem = self.editButtonItem; // Called when the user toggles the edit/done button - (void)setEditing:(BOOL)editing animated:(BOOL)animated - (void)setEditing:(BOOL)editing animated:(BOOL)animated { } { // Update appearance of views }
    21. 21. Custom Title View вместо надписи • Arbitrary view in place of the title UISegmentedControl *segmentedControl = ... self.navigationItem.titleView = segmentedControl; [segmentedControl release];Thursday, January 28, 2010 28
    22. 22. UITabBarController UITabBarController UITabBarController • Array of view controllers • Tab bar • Array of view controllers • Tab bar View Controller Tab Bar View Controller Controller View Controller Tab Bar ControllerThursday, January 28, 2010 32
    23. 23. используем UITabBarController- (void)applicationDidFinishLaunching{ tabBarController = [[UITabBarController alloc] init]; NSArray *myViewControllers = [NSArray arrayWithObjects:someViewController, nil]; tabBarController.viewControllers = myViewControllers; [window addSubview:tabBarController.view];}
    24. 24. добавляем картинку иCreating Tab надпись Bar Items• Title and image - (void)viewDidLoad { UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@“Playlists” image:[UIImage imageNamed:@“music.png”] tag:0]; self.tabBarItem = item; [item release]; }
    25. 25. стандартный набор Creating Tab Bar Items • System item - (void)viewDidLoad { UITabBarItem *item = [[UITabBarItem alloc] initWithTabBarSystemItem: UITabBarSystemItemBookmarks tag:0] self.tabBarItem = item; [item release]; }Thursday, January 28, 2010 37
    26. 26. ollers а если слишком More View Controllers • много?b bar controller has too many a tab bar controller has too many What happens wheny at once? view controllers to display at once? ! “More” tab bar item displayed automatically ! User can navigate to remaining view controllers
    27. 27. Tab Bar + Navigation Controllers Multiple parallel hierarchiesThursday, January 28, 2010 41
    28. 28. архитектура Tab Bar + Navigation Controllers Navigation Controller View Controller NavigationTab Bar Controller Controller View Controller View Controller
    29. 29. домашка!
    30. 30. http://empatika.comoleg.parinov@empatika.com

    ×