. iOS. 10. iPad

  • Published on
    29-Nov-2014

  • View
    367

  • Download
    9

DESCRIPTION

 

Transcript

  • 1. iPad iOS 10 gleb34@gmail.com
  • 2.
  • 3. view?
  • 4. view? [UIView animateWithDuration:0.3 animations:^{ self.smallView.frame = ...; }];
  • 5. ?
  • 6. ? [UIView animateWithDuration:0.3 animations:^{ // } completion:^(BOOL finished) { [UIView animateWithDuration:0.3 animations:^{ // }]; }];
  • 7. view ? ( UILabel)
  • 8. view ? ( UILabel) id a = [UILabel appearance]; [a setTextColor:[UIColor redColor]];
  • 9. iPad
  • 10.
  • 11. Storyboard Storyboard , : Storyboard Storyboard: iPhone, iPad,
  • 12. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { ... } + (BOOL)isIpad { return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad); } ! ! ! if ([Utils isIpad]) ...
  • 13. Storyboard
  • 14. - (void)viewDidLoad { [super viewDidLoad]; if ([Utils isIpad]) { // iPad } } Storyboard
  • 15. Storyboard, - (IBAction)buttonTapped { if ([Utils isIpad]) { // iPad } else { // iPhone } }
  • 16. iPad- iPhone @interface ViewController_iPad : ViewController ! @end ! ! ! ! ! ! - (IBAction)buttonTapped { ... }
  • 17. @interface ViewController_iPad : ViewController ! @end ! ! ! @interface ViewController_iPhone : ViewController ! @end
  • 18. Storyboard @interface AppDelegate : UIResponder ! + (AppDelegate *)instance; ! - (UIStoryboard *)iphoneStoryboard; - (UIStoryboard *)ipadStoryboard; - (UIStoryboard *)generalStoryboard; ! @property (strong, nonatomic) UIWindow *window; ! @end
  • 19. + (AppDelegate *)instance { return [[UIApplication sharedApplication] delegate]; } ! ! ! ! - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.iphoneStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil]; self.ipadStoryboard = [UIStoryboard storyboardWithName:@"Main_iPad" bundle:nil]; self.generalStoryboard = [UIStoryboard storyboardWithName:@"General" bundle:nil]; return YES; }
  • 20. - (IBAction)buttonTapped { UIStoryboard *s = [AppDelegate instance].generalStoryboard; ! MenuViewController *m = [s instantiateViewControllerWithIdentifier:@"MenuViewController"]; ! [self presentViewController:m animated:YES completion:nil]; }
  • 21. autosizing & autolayouts
  • 22. @implementation MyView ! - (void)layoutSubviews { [super layoutSubviews]; ! ... } ! @end @interface MyView : UIView ! @end layoutSubviews
  • 23. @implementation ViewController ! - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; ... } ! - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; ... } ! @end
  • 24. - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; CGRect frame = self.smallView.frame; frame.origin.x = (self.view.frame.size.width - frame.size.width) / 2; frame.origin.y = (self.view.frame.size.height - frame.size.height) / 2; self.smallView.frame = frame; }
  • 25. Auto Layout
  • 26.
  • 27. @implementation ViewController ! - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } ! @end
  • 28. UINavigationController @interface CustomNavigationController : UINavigationController ! @end @implementation CustomNavigationController ! - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } ! @end
  • 29. @implementation CustomNavigationController ! - (NSUInteger)supportedInterfaceOrientations { return self.topViewController.supportedInterfaceOrientations; } ! - (BOOL)shouldAutorotate { return self.topViewController.shouldAutorotate; } ! @end
  • 30. UISplitViewController
  • 31. , UISplitViewControllerDelegate
  • 32. UIPopoverController
  • 33. iPad , iPad iPad
  • 34. ! gleb34@gmail.com twitter.com/pilot34