storyboards and controllers on os x - apple inc.€¦ · storyboards and controllers on os x...

178
© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. #WWDC14 Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks Raleigh Ledet AppKit Engineer

Upload: others

Post on 14-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

#WWDC14

Storyboards and Controllers on OS XContain yourself

Session 212 Mike Swingler Interface Builder Engineer

Frameworks

!

Raleigh Ledet AppKit Engineer

Page 2: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

IntroductionCool new API concepts

Storyboards

View controllers

Window controllers

Gesture recognizers

!

Page 3: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

StoryboardsLines and boxes and segues, oh my

Page 4: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XXcode

Page 5: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XXcode

Page 6: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XXcode

Page 7: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XXcode

Page 8: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XXcode

Page 9: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XXcode

Page 10: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XXcode

Page 11: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XXcode

Page 12: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XView Controllers

Connection between model and view

Page 13: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XView Controllers

Connection between model and view

Page 14: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XView Controllers

Connection between model and view

Place views

Page 15: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XView Controllers

Connection between model and view

Place views

Page 16: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XView Controllers

Connection between model and view

Place views

Setup Auto Layout constraints

Page 17: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XView Controllers

Connection between model and view

Place views

Setup Auto Layout constraints

Connect actions and outlets

Page 18: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XView Controllers

Connection between model and view

Place views

Setup Auto Layout constraints

Connect actions and outlets

Page 19: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XView Controllers

Connection between model and view

Place views

Setup Auto Layout constraints

Connect actions and outlets

Page 20: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XView Controllers

Connection between model and view

Place views

Setup Auto Layout constraints

Connect actions and outlets

Page 21: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XSegues

Page 22: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XSegues

Page 23: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XSegues

Containment

Window

Split

Tab

Page 24: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XSegues

Containment

Window

Split

Tab

Presentation

Modal

Sheet

Popover

Page 25: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XSegues

Containment

Window

Split

Tab

Presentation

Modal

Sheet

Popover

- (void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender;

Page 26: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Page 27: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Page 28: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Page 29: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Page 30: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Page 31: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Page 32: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Page 33: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Page 34: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Pages.storyboardc

Page 35: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Pages.storyboardc

Page 36: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Pages.storyboardc

Page 37: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Pages.storyboardc

Page 38: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Pages.storyboardc

Pages.app

Page 39: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboards on OS XBuild and run time

Page 40: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

DemoGetting started with Storyboards on OS X

Mike Swingler

Page 41: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

APILooking under the hood

Raleigh Ledet AppKit Engineer

Page 42: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

APILooking under the hood

Storyboards

View controllers

Window controllers

Gesture recognizers

Page 43: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboard

Page 44: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboard

NSMainStoryboardFile

Page 45: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboard

+ (instancetype)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil; !

- (id)instantiateInitialController; !

- (id)instantiateControllerWithIdentifier:(NSString *)identifier;

Page 46: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboard

+ (instancetype)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil; !

- (id)instantiateInitialController; !

- (id)instantiateControllerWithIdentifier:(NSString *)identifier;

Page 47: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboard

+ (instancetype)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil; !

- (id)instantiateInitialController; !

- (id)instantiateControllerWithIdentifier:(NSString *)identifier;

Page 48: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Storyboard

+ (instancetype)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil; !

- (id)instantiateInitialController; !

- (id)instantiateControllerWithIdentifier:(NSString *)identifier;

Page 49: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewController

Loading and layout

Containers

Triggered segues

Manual presentation

!

Page 50: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerView loading, display, and layout

@property (readonly, getter=isViewLoaded) BOOL viewLoaded; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

Page 51: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = NO; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

-init

Page 52: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = NO; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

-loadView

Page 53: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

V

-loadView -setView:

Page 54: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

V

-loadView -setView:

Page 55: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

V

Page 56: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

V

Page 57: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

VV

V

-addSubview: -setHidden:NO !

-orderFront:

VV

Page 58: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

V

VV

V

VV

Page 59: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

VV

VV

V

VV

Page 60: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

V

VV

V

V

V

V

V

VV

V

-orderOut: -setHidden:YES -removeFromSuperview

Page 61: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

VV

V

V

VV

V

V

V

VV

Page 62: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

@property (readonly, getter=isViewLoaded) BOOL viewLoaded = YES; - (void)viewDidLoad; - (void)viewWillAppear; - (void)viewDidAppear; - (void)viewWillDisappear; - (void)viewDidDisappear; !

- (void)updateViewConstraints; - (void)viewWillLayout; - (void)viewDidLayout;

ViewController

NSViewControllerView loading, display, and layout

VV

V

V

VV

V

V

V

VV

Page 63: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerNow in responder chain!

Page 64: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerNow in responder chain!

CanvasView

Page 65: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerNow in responder chain!

Window’s WindowControllerCanvasView NSSplitView Window

Page 66: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerNow in responder chain!

Window’s WindowControllerCanvasView NSSplitView Window

CanvasView Controller

NSSplitView Controller

Page 67: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerNow in responder chain!

Window’s WindowControllerCanvasView NSSplitView Window

CanvasView Controller

NSSplitView Controller

Page 68: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

Page 69: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewController

Page 70: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewController

Manages an NSTabView

Page 71: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewController

Manages an NSTabView

Lazily loads tab views

Page 72: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewController

Manages an NSTabView

Lazily loads tab views

Easy tab customization

Page 73: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewController

Manages an NSTabView

Lazily loads tab views

Easy tab customization

Easily use toolbar as tab switcher

Page 74: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Properties of NSTabViewItem !

-identifier -label -tooltip

NSTabViewControllerContainment

NSTabView

NSTabViewItem NSTabViewItem NSTabViewItem

view view view

Page 75: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Properties of NSTabViewItem !

-identifier -label -tooltip

NSTabViewControllerContainment

NSTabView

NSTabViewItem NSTabViewItem NSTabViewItem

view view view

Page 76: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Properties of NSTabViewItem !

-identifier -label -tooltip

NSTabViewControllerContainment

NSTabView

NSTabViewItem NSTabViewItem NSTabViewItem

view view view

Page 77: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerContainment

Properties of NSTabViewItem !

-identifier -label -color -tooltip -viewController -image

NSTabViewItem NSTabViewItem NSTabViewItem

view view view

NSTabView

Page 78: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerContainment

Properties of NSTabViewItem !

-identifier -label -color -tooltip -viewController -image

NSTabViewItem NSTabViewItem NSTabViewItem

view view view

NSTabViewController

NSViewController NSViewController NSViewController

NSTabView

Page 79: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerContainment

@property (copy) NSArray *tabViewItems; @property NSInteger selectedTabViewItemIndex; !

- (void)addTabViewItem:(NSTabViewItem *)tabViewItem; - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem atIndex:(NSInteger)index; - (void)removeTabViewItem:(NSTabViewItem *)tabViewItem; !

- (NSTabViewItem *)tabViewItemForViewController:(NSViewController *)vc;

NSTabViewItem NSTabViewItem

Page 80: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerContainment

@property (copy) NSArray *tabViewItems; @property NSInteger selectedTabViewItemIndex; !

- (void)addTabViewItem:(NSTabViewItem *)tabViewItem; - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem atIndex:(NSInteger)index; - (void)removeTabViewItem:(NSTabViewItem *)tabViewItem; !

- (NSTabViewItem *)tabViewItemForViewController:(NSViewController *)vc;

NSTabViewItem NSTabViewItem

Page 81: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerContainment

@property (copy) NSArray *tabViewItems; @property NSInteger selectedTabViewItemIndex; !

- (void)addTabViewItem:(NSTabViewItem *)tabViewItem; - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem atIndex:(NSInteger)index; - (void)removeTabViewItem:(NSTabViewItem *)tabViewItem; !

- (NSTabViewItem *)tabViewItemForViewController:(NSViewController *)vc;

NSTabViewItem NSTabViewItem

Page 82: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerContainment

@property (copy) NSArray *tabViewItems; @property NSInteger selectedTabViewItemIndex; !

- (void)addTabViewItem:(NSTabViewItem *)tabViewItem; - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem atIndex:(NSInteger)index; - (void)removeTabViewItem:(NSTabViewItem *)tabViewItem; !

- (NSTabViewItem *)tabViewItemForViewController:(NSViewController *)vc;

NSTabViewItem NSTabViewItem

Page 83: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerContainment

@property (copy) NSArray *tabViewItems; @property NSInteger selectedTabViewItemIndex; !

- (void)addTabViewItem:(NSTabViewItem *)tabViewItem; - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem atIndex:(NSInteger)index; - (void)removeTabViewItem:(NSTabViewItem *)tabViewItem; !

- (NSTabViewItem *)tabViewItemForViewController:(NSViewController *)vc;

NSTabViewItem NSTabViewItem

Page 84: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerContainment

@property (copy) NSArray *tabViewItems; @property NSInteger selectedTabViewItemIndex; !

- (void)addTabViewItem:(NSTabViewItem *)tabViewItem; - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem atIndex:(NSInteger)index; - (void)removeTabViewItem:(NSTabViewItem *)tabViewItem; !

- (NSTabViewItem *)tabViewItemForViewController:(NSViewController *)vc; !

@interface NSTabViewItem + (instancetype)tabViewItemWithViewController:(NSViewController *)vc;

NSTabViewItem NSTabViewItem

Page 85: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerProperties

@property NSTabViewControllerTabStyle tabStyle; @property (strong) NSSegmentedControl *segmentedControl; @property NSViewControllerTransitionOptions transitionOptions; @property (strong) NSTabView *tabView;

Page 86: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerProperties

@property NSTabViewControllerTabStyle tabStyle; @property (strong) NSSegmentedControl *segmentedControl; @property NSViewControllerTransitionOptions transitionOptions; @property (strong) NSTabView *tabView;

Page 87: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerProperties

@property NSTabViewControllerTabStyle tabStyle; @property (strong) NSSegmentedControl *segmentedControl; @property NSViewControllerTransitionOptions transitionOptions; @property (strong) NSTabView *tabView;

NSTabViewControllerTabStyleSegmentedControlOnTop NSTabViewControllerTabStyleSegmentedControlOnBottom NSTabViewControllerTabStyleToolbar NSTabViewControllerTabStyleUnspecified

Page 88: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerProperties

@property NSTabViewControllerTabStyle tabStyle; @property (strong) NSSegmentedControl *segmentedControl; @property NSViewControllerTransitionOptions transitionOptions; @property (strong) NSTabView *tabView;

Page 89: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerProperties

@property NSTabViewControllerTabStyle tabStyle; @property (strong) NSSegmentedControl *segmentedControl; @property NSViewControllerTransitionOptions transitionOptions; @property (strong) NSTabView *tabView;

Page 90: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerProperties

@property NSTabViewControllerTabStyle tabStyle; @property (strong) NSSegmentedControl *segmentedControl; @property NSViewControllerTransitionOptions transitionOptions; @property (strong) NSTabView *tabView;

Page 91: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerProperties

@property NSTabViewControllerTabStyle tabStyle; @property (strong) NSSegmentedControl *segmentedControl; @property NSViewControllerTransitionOptions transitionOptions; @property (strong) NSTabView *tabView;

NSViewControllerTransitionNone NSViewControllerTransitionCrossfade !

NSViewControllerTransitionSlideUp NSViewControllerTransitionSlideDown NSViewControllerTransitionSlideLeft NSViewControllerTransitionSlideRight NSViewControllerTransitionSlideForward NSViewControllerTransitionSlideBackward

Page 92: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerProperties

@property NSTabViewControllerTabStyle tabStyle; @property (strong) NSSegmentedControl *segmentedControl; @property NSViewControllerTransitionOptions transitionOptions; @property (strong) NSTabView *tabView;

Page 93: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerProperties

@property NSTabViewControllerTabStyle tabStyle; @property (strong) NSSegmentedControl *segmentedControl; @property NSViewControllerTransitionOptions transitionOptions; @property (strong) NSTabView *tabView;

Page 94: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerNSToolbarDelegate

- (NSToolbarItem *)toolbar:(NSToolbar *)tb itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag NS_REQUIRES_SUPER; !

- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)tb NS_REQUIRES_SUPER; - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)tb NS_REQUIRES_SUPER; - (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)tb NS_REQUIRES_SUPER;

Page 95: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSTabViewControllerNSToolbarDelegate

- (NSToolbarItem *)toolbar:(NSToolbar *)tb itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag NS_REQUIRES_SUPER; !

- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)tb NS_REQUIRES_SUPER; - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)tb NS_REQUIRES_SUPER; - (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)tb NS_REQUIRES_SUPER;

Page 96: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewController

Page 97: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewController

Manages an NSSplitView

Page 98: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewController

Manages an NSSplitView

Lazy loading of views

Page 99: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewController

Manages an NSSplitView

Lazy loading of views

Requires Auto Layout

Page 100: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewControllerContainment

NSSplitView

view view

Page 101: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewControllerContainment

view view

NSSplitView

Page 102: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewControllerContainment

view view

NSSplitViewController

NSSplitViewItem NSSplitViewItem

NSViewController NSViewController

NSSplitView

Page 103: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Properties of NSSplitViewItem !

!

!

!

!

!

@property (getter=isCollapsed) BOOL collapsed; @property BOOL canCollapse; @property NSLayoutPriority holdingPriority; @property (strong) NSViewController *viewController; + (instancetype)splitViewItemWithViewController:(NSViewController *)vc;

NSSplitViewControllerContainment

NSSplitViewController

view view

NSSplitViewItem NSSplitViewItem

NSViewController NSViewController

NSSplitView

Page 104: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Properties of NSSplitViewItem !

!

!

!

!

!

@property (getter=isCollapsed) BOOL collapsed; @property BOOL canCollapse; @property NSLayoutPriority holdingPriority; @property (strong) NSViewController *viewController; + (instancetype)splitViewItemWithViewController:(NSViewController *)vc;

[[splitViewItem animator] setCollapse:YES]

NSSplitViewControllerContainment

NSSplitViewController

view view

NSSplitViewItem NSSplitViewItem

NSViewController NSViewController

NSSplitView

Page 105: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewControllerContainment

@property (copy) NSArray *splitViewItems; !

- (void)addSplitViewItem:(NSSplitViewItem *)splitViewItem; - (void)insertSplitViewItem:(NSSplitViewItem *)splitViewItem atIndex:(NSInteger)index; - (void)removeSplitViewItem:(NSSplitViewItem *)splitViewItem; !

- (NSSplitViewItem *)splitViewItemForViewController:(NSViewController *)vc;

NSSplitViewItem NSSplitViewItem

Page 106: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewControllerContainment

@property (copy) NSArray *splitViewItems; !

- (void)addSplitViewItem:(NSSplitViewItem *)splitViewItem; - (void)insertSplitViewItem:(NSSplitViewItem *)splitViewItem atIndex:(NSInteger)index; - (void)removeSplitViewItem:(NSSplitViewItem *)splitViewItem; !

- (NSSplitViewItem *)splitViewItemForViewController:(NSViewController *)vc;

NSSplitViewItem NSSplitViewItem

Page 107: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewControllerContainment

@property (copy) NSArray *splitViewItems; !

- (void)addSplitViewItem:(NSSplitViewItem *)splitViewItem; - (void)insertSplitViewItem:(NSSplitViewItem *)splitViewItem atIndex:(NSInteger)index; - (void)removeSplitViewItem:(NSSplitViewItem *)splitViewItem; !

- (NSSplitViewItem *)splitViewItemForViewController:(NSViewController *)vc;

NSSplitViewItem NSSplitViewItem

Page 108: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSSplitViewControllerContainment

@property (copy) NSArray *splitViewItems; !

- (void)addSplitViewItem:(NSSplitViewItem *)splitViewItem; - (void)insertSplitViewItem:(NSSplitViewItem *)splitViewItem atIndex:(NSInteger)index; - (void)removeSplitViewItem:(NSSplitViewItem *)splitViewItem; !

- (NSSplitViewItem *)splitViewItemForViewController:(NSViewController *)vc;

NSSplitViewItem NSSplitViewItem

Page 109: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

NSViewController

NSTabViewController

NSSplitViewController

MyCollectionViewController

MyCollectionItem MyCollectionItem

NSViewController NSViewController

view view

Page 110: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

@property (copy) NSArray *childViewControllers; - (void)addChildViewController:(NSViewController *)childViewController; - (void)insertChildViewController:(NSViewController *)childViewController atIndex:(NSInteger)index; - (void)removeChildViewControllerAtIndex:(NSInteger)index; !

@property (readonly) NSViewController *parentViewController; - (void)removeFromParentViewController;

NSViewController

NSViewController NSViewController NSViewController

Page 111: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

@property (copy) NSArray *childViewControllers; - (void)addChildViewController:(NSViewController *)childViewController; - (void)insertChildViewController:(NSViewController *)childViewController atIndex:(NSInteger)index; - (void)removeChildViewControllerAtIndex:(NSInteger)index; !

@property (readonly) NSViewController *parentViewController; - (void)removeFromParentViewController;

NSViewController

NSViewController NSViewController NSViewController

Page 112: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

@property (copy) NSArray *childViewControllers; - (void)addChildViewController:(NSViewController *)childViewController; - (void)insertChildViewController:(NSViewController *)childViewController atIndex:(NSInteger)index; - (void)removeChildViewControllerAtIndex:(NSInteger)index; !

@property (readonly) NSViewController *parentViewController; - (void)removeFromParentViewController;

NSViewController

NSViewController NSViewController NSViewController

Page 113: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

@property (copy) NSArray *childViewControllers; - (void)addChildViewController:(NSViewController *)childViewController; - (void)insertChildViewController:(NSViewController *)childViewController atIndex:(NSInteger)index; - (void)removeChildViewControllerAtIndex:(NSInteger)index; !

@property (readonly) NSViewController *parentViewController; - (void)removeFromParentViewController;

NSViewController

NSViewController NSViewController NSViewController

Page 114: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

- (void)transitionFromViewController:(NSViewController *)fromViewController toViewController:(NSViewController *)toViewController options:(NSViewControllerTransitionOptions)options completionHandler:(void (^)(void))completion;

Page 115: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

- (void)transitionFromViewController:(NSViewController *)fromViewController toViewController:(NSViewController *)toViewController options:(NSViewControllerTransitionOptions)options completionHandler:(void (^)(void))completion;

NSViewControllerTransitionNone NSViewControllerTransitionCrossfade !

NSViewControllerTransitionSlideUp NSViewControllerTransitionSlideDown NSViewControllerTransitionSlideLeft NSViewControllerTransitionSlideRight NSViewControllerTransitionSlideForward NSViewControllerTransitionSlideBackward

Page 116: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

- (void)transitionFromViewController:(NSViewController *)fromViewController toViewController:(NSViewController *)toViewController options:(NSViewControllerTransitionOptions)options completionHandler:(void (^)(void))completion;

Page 117: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerContainment

NSViewController

NSTabViewController

NSSplitViewController

MyCollectionViewController

MyCollectionItem MyCollectionItem

NSViewController NSViewController

view view

Page 118: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewController

Loading and layout

Containers

Triggered segues

Manual presentation

!

Page 119: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewController

Presentation

Triggered segues

Page 120: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewController

Presentation

• Identifier

Triggered segues

Page 121: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewController

Presentation

• Identifier

• Source view controller

Triggered segues

Page 122: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewController

Presentation

• Identifier

• Source view controller

• Destination controller

Triggered segues

Page 123: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewController

Presentation

• Identifier

• Source view controller

• Destination controller

• Style

Triggered segues

Page 124: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewController

Presentation

• Identifier

• Source view controller

• Destination controller

• Style

• Other attributes

Triggered segues

Page 125: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerTriggered segues

- (void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender;

!

Page 126: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerTriggered segues

- (void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender; !

@interface NSStoryboardSegue @property (readonly, copy) NSString *identifier; @property (readonly, strong) id sourceController; @property (readonly, strong) id destinationController;

Page 127: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerTriggered segues

- (void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender; !

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender;

Page 128: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerTriggered segues

- (void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender; !

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender; !

- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender;

Page 129: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerTriggered segues

Page 130: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerTriggered segues

- (void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender;

Page 131: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerManual presentation

Page 132: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerManual presentation

- (void)presentViewControllerAsSheet:(NSViewController *)vc; !

- (void)presentViewControllerAsModalWindow:(NSViewController *)vc; !

- (void)presentViewController:(NSViewController *)vc asPopoverRelativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView preferredEdge:(NSRectEdge)preferredEdge behavior:(NSPopoverBehavior)behavior; !

- (IBAction)dismissController:(id)sender;

Page 133: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerManual presentation

- (void)presentViewControllerAsSheet:(NSViewController *)vc; !

- (void)presentViewControllerAsModalWindow:(NSViewController *)vc; !

- (void)presentViewController:(NSViewController *)vc asPopoverRelativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView preferredEdge:(NSRectEdge)preferredEdge behavior:(NSPopoverBehavior)behavior; !

- (IBAction)dismissController:(id)sender;

Page 134: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerManual presentation

- (void)presentViewControllerAsSheet:(NSViewController *)vc; !

- (void)presentViewControllerAsModalWindow:(NSViewController *)vc; !

- (void)presentViewController:(NSViewController *)vc asPopoverRelativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView preferredEdge:(NSRectEdge)preferredEdge behavior:(NSPopoverBehavior)behavior; !

- (IBAction)dismissController:(id)sender;

Page 135: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerManual presentation

- (void)presentViewControllerAsSheet:(NSViewController *)vc; !

- (void)presentViewControllerAsModalWindow:(NSViewController *)vc; !

- (void)presentViewController:(NSViewController *)vc asPopoverRelativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView preferredEdge:(NSRectEdge)preferredEdge behavior:(NSPopoverBehavior)behavior; !

- (IBAction)dismissController:(id)sender;

Page 136: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerManual presentation

- (void)presentViewControllerAsSheet:(NSViewController *)vc; !

- (void)presentViewControllerAsModalWindow:(NSViewController *)vc; !

- (void)presentViewController:(NSViewController *)vc asPopoverRelativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView preferredEdge:(NSRectEdge)preferredEdge behavior:(NSPopoverBehavior)behavior; !

- (IBAction)dismissController:(id)sender;

Page 137: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerManual presentation

- (void)presentViewController:(NSViewController *)viewController animator:(id <NSViewControllerPresentationAnimator>)animator;

Page 138: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerManual presentation

- (void)presentViewController:(NSViewController *)viewController animator:(id <NSViewControllerPresentationAnimator>)animator;

Page 139: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSViewControllerManual presentation

- (void)presentViewController:(NSViewController *)viewController animator:(id <NSViewControllerPresentationAnimator>)animator; !

@protocol - (void)animatePresentationOfViewController:(NSViewController *)vc fromViewController:(NSViewController *)fromViewController; !

- (void)animateDismissalOfViewController:(NSViewController *)vc fromViewController:(NSViewController *)fromViewController;

Page 140: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

APILooking under the hood

Storyboards

View controllers

Window controllers

Gesture recognizers

Page 141: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSWindowController

!

Page 142: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSWindowController

@property (strong) NSViewController *contentViewController; @property(readonly, strong) NSStoryboard *storyboard; - (IBAction)dismissController:(id)sender;

Page 143: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSWindowController

@property (strong) NSViewController *contentViewController; @property(readonly, strong) NSStoryboard *storyboard; - (IBAction)dismissController:(id)sender;

Page 144: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSWindowController

@property (strong) NSViewController *contentViewController; @property(readonly, strong) NSStoryboard *storyboard; - (IBAction)dismissController:(id)sender;

Page 145: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSWindowController

@property (strong) NSViewController *contentViewController; @property(readonly, strong) NSStoryboard *storyboard; - (IBAction)dismissController:(id)sender;

Page 146: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSWindowController

@property (strong) NSViewController *contentViewController; @property(readonly, strong) NSStoryboard *storyboard; - (IBAction)dismissController:(id)sender; !

- (void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender; - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender; - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender;

Page 147: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSWindowController

Manage window

Page 148: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSWindowController

Manage window

Manage titlebar and toolbar

Page 149: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSWindowController

Manage window

Manage titlebar and toolbar

Manage the contentViewController

Page 150: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

APILooking under the hood

Storyboards

View controllers

Window controllers

Gesture recognizers

Page 151: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

Page 152: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

Most gestures are determined by hardware (but not all)

Page 153: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

Most gestures are determined by hardware (but not all)

Disambiguating user input

Page 154: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

Most gestures are determined by hardware (but not all)

Disambiguating user input

- (void)mouseDown:(NSEvent *)downEvent { CGFloat doubleClickTime = [NSEvent doubleClickInterval]; NSEventMask eventMask = NSLeftMouseDraggedMask | NSLeftMouseUpMask; // Is this a singe, double or triple click? Or long click, or a drag? NSEvent *nextEvent = [NSApp nextEventMatchingMask:eventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]; if (nextEvent) { // could be an up or a drag if (nextEvent.type == NSLeftMouseUp) { // got at least a single click, make sure it's not performing a double click if ( (nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseDownMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]) ) { // start of a double (or triple) click if ( (nextEvent = [NSApp nextEventMatchingMask:eventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]) ) { if (nextEvent.type == NSLeftMouseUp) { // got at least a double click, make sure user is not performing a triple click if ( (nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseDownMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]) ) { // start of a triple click? if ( (nextEvent = [NSApp nextEventMatchingMask:eventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]) ) { if (nextEvent.type == NSLeftMouseUp) { // triple click! This is as far as we care about [self handleTripleClick]; } else { // double click and drag. That means nothing to us. Eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } } else { // double click and a half. That means nothing to us. Eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } } else { // double click! [self handleDoubleClick]; } } else { // tap and a drag, That means nothing to us. Eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } } else { // tap and a half. That means nothing to us. Eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } } else { // This is a single click. This view doesn't care about single clicks, but perhaps the superview cares. [NSApp postEvent:nextEvent atStart:YES]; [super mouseDown:downEvent]; } } else { [NSApp postEvent:nextEvent atStart:YES]; [self handleMouseDragWithEvent:downEvent]; } } else { // a long single click [self handleLongClick]; // eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } }

Page 155: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

Most gestures are determined by hardware (but not all)

Disambiguating user input

- (void)mouseDown:(NSEvent *)downEvent { CGFloat doubleClickTime = [NSEvent doubleClickInterval]; NSEventMask eventMask = NSLeftMouseDraggedMask | NSLeftMouseUpMask; // Is this a singe, double or triple click? Or long click, or a drag? NSEvent *nextEvent = [NSApp nextEventMatchingMask:eventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]; if (nextEvent) { // could be an up or a drag if (nextEvent.type == NSLeftMouseUp) { // got at least a single click, make sure it's not performing a double click if ( (nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseDownMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]) ) { // start of a double (or triple) click if ( (nextEvent = [NSApp nextEventMatchingMask:eventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]) ) { if (nextEvent.type == NSLeftMouseUp) { // got at least a double click, make sure user is not performing a triple click if ( (nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseDownMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]) ) { // start of a triple click? if ( (nextEvent = [NSApp nextEventMatchingMask:eventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:doubleClickTime] inMode:NSEventTrackingRunLoopMode dequeue:YES]) ) { if (nextEvent.type == NSLeftMouseUp) { // triple click! This is as far as we care about [self handleTripleClick]; } else { // double click and drag. That means nothing to us. Eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } } else { // double click and a half. That means nothing to us. Eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } } else { // double click! [self handleDoubleClick]; } } else { // tap and a drag, That means nothing to us. Eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } } else { // tap and a half. That means nothing to us. Eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } } else { // This is a single click. This view doesn't care about single clicks, but perhaps the superview cares. [NSApp postEvent:nextEvent atStart:YES]; [super mouseDown:downEvent]; } } else { [NSApp postEvent:nextEvent atStart:YES]; [self handleMouseDragWithEvent:downEvent]; } } else { // a long single click [self handleLongClick]; // eat all events until we get a mouse up nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseUp untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent]; } }

Page 156: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

Most gestures are determined by hardware (but not all)

Disambiguating user input

Page 157: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

Most gestures are determined by hardware (but not all)

Disambiguating user input

Good fit for view controllers (target of action)

Page 158: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSGestureRecognizer *gr = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self action:@selector(magnify:)]; [self.view addGestureRecognizer:gr]; gr.delegate = self; !

- (void)magnify:(NSClickGestureRecognizer*)gr { switch (gr.state) { case NSGestureRecognizerStateBegan: … case NSGestureRecognizerStateChanged: … case NSGestureRecognizerStateEnded: … case NSGestureRecognizerStateCancelled: … }}

Page 159: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSGestureRecognizer *gr = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self action:@selector(magnify:)]; [self.view addGestureRecognizer:gr]; gr.delegate = self; !

- (void)magnify:(NSClickGestureRecognizer*)gr { switch (gr.state) { case NSGestureRecognizerStateBegan: … case NSGestureRecognizerStateChanged: … case NSGestureRecognizerStateEnded: … case NSGestureRecognizerStateCancelled: … }}

Page 160: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSGestureRecognizer *gr = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self action:@selector(magnify:)]; [self.view addGestureRecognizer:gr]; gr.delegate = self; !

- (void)magnify:(NSClickGestureRecognizer*)gr { switch (gr.state) { case NSGestureRecognizerStateBegan: … case NSGestureRecognizerStateChanged: … case NSGestureRecognizerStateEnded: … case NSGestureRecognizerStateCancelled: … }}

Page 161: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSGestureRecognizer *gr = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self action:@selector(magnify:)]; [self.view addGestureRecognizer:gr]; gr.delegate = self; !

- (void)magnify:(NSClickGestureRecognizer*)gr { switch (gr.state) { case NSGestureRecognizerStateBegan: … case NSGestureRecognizerStateChanged: … case NSGestureRecognizerStateEnded: … case NSGestureRecognizerStateCancelled: … }}

Page 162: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSGestureRecognizer *gr = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self action:@selector(magnify:)]; [self.view addGestureRecognizer:gr]; gr.delegate = self; !

- (void)magnify:(NSClickGestureRecognizer*)gr { switch (gr.state) { case NSGestureRecognizerStateBegan: … case NSGestureRecognizerStateChanged: … case NSGestureRecognizerStateEnded: … case NSGestureRecognizerStateCancelled: … }}

Page 163: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSGestureRecognizer *gr = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self action:@selector(magnify:)]; [self.view addGestureRecognizer:gr]; gr.delegate = self; !

- (void)magnify:(NSClickGestureRecognizer*)gr { switch (gr.state) { case NSGestureRecognizerStateBegan: … case NSGestureRecognizerStateChanged: … case NSGestureRecognizerStateEnded: … case NSGestureRecognizerStateCancelled: … }}

Page 164: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSGestureRecognizer *gr = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self action:@selector(magnify:)]; [self.view addGestureRecognizer:gr]; gr.delegate = self; !

- (void)magnify:(NSClickGestureRecognizer*)gr { switch (gr.state) { case NSGestureRecognizerStateBegan: … case NSGestureRecognizerStateChanged: … case NSGestureRecognizerStateEnded: … case NSGestureRecognizerStateCancelled: … }}

Page 165: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSClickGestureRecognizer

NSPanGestureRecognizer

NSPressGestureRecognizer

NSMagnificationGestureRecognizer

NSRotationGestureRecognizer

Page 166: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSClickGestureRecognizer

NSPanGestureRecognizer

NSPressGestureRecognizer

NSMagnificationGestureRecognizer

NSRotationGestureRecognizer

Page 167: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSClickGestureRecognizer

NSPanGestureRecognizer

NSPressGestureRecognizer

NSMagnificationGestureRecognizer

NSRotationGestureRecognizer

Page 168: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSClickGestureRecognizer

NSPanGestureRecognizer

NSPressGestureRecognizer

NSMagnificationGestureRecognizer

NSRotationGestureRecognizer

Page 169: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizer

NSClickGestureRecognizer

NSPanGestureRecognizer

NSPressGestureRecognizer

NSMagnificationGestureRecognizer

NSRotationGestureRecognizer

Page 170: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizerEvent flow

NSView -mouseDown:

NSApplication -sendEvent:

NSWindow -sendEvent:

Responder ChainEvent Observers

Mouse press

Page 171: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizerEvent flow

NSView -mouseDown:

NSApplication -sendEvent:

NSWindow -sendEvent:

Responder ChainEvent Observers

Mouse press

Gesture Recognizers

Page 172: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

NSGestureRecognizerFor subclassers

See NSGestureRecognizer (NSSubclassUse)

Page 173: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

DemoView controllers and gesture recognizers

Raleigh Ledet AppKit Engineer

Page 174: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

SummaryLooking under the hood

Storyboards

View controllers

Window controllers

Gesture recognizers

Page 175: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

More Information

Jake Behrens App Frameworks Evangelist [email protected]

Documentation What’s New in OS X http://developer.apple.com/

Apple Developer Forums http://devforums.apple.com

Page 176: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

Related Sessions

• Adapting Your App to the New UI of OS X Yosemite

Pacific Heights Tuesday 3:15PM

• Adopting Advanced Features of the New UI of OS X Yosemite

Marina Wednesday 2:00PM

• What's New in Interface Builder Mission Wednesday 3:15PM

• Creating Modern Cocoa Apps Marina Thursday 10:15AM

Page 177: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh

• Interface Builder and Live Views Lab Tools Lab C Wednesday 9:00AM

• New UI and Cocoa Lab Frameworks Lab B Wednesday 3:15PM

• Xcode and Interface Builder Lab Tools Lab C Thursday 9:00AM

• View Controllers and Cocoa Lab Frameworks Lab B Thursday 11:30AM

• Cocoa Lab Frameworks Lab B Thursday 4:30PM

• Interface Builder and Auto Layout Lab Tools Lab C Friday 9:00AM

Labs

Page 178: Storyboards and Controllers on OS X - Apple Inc.€¦ · Storyboards and Controllers on OS X Contain yourself Session 212 Mike Swingler Interface Builder Engineer Frameworks! Raleigh