162
© 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Enhancing your apps for the next dimension of touch App Frameworks #WWDC16 Session 228 A Peek at 3D Touch Tyler Fox UIKit Frameworks Engineer Peter Hajas UIKit Frameworks Engineer

228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

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

Enhancing your apps for the next dimension of touch

App Frameworks #WWDC16

Session 228

A Peek at 3D Touch

Tyler Fox UIKit Frameworks EngineerPeter Hajas UIKit Frameworks Engineer

Page 2: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Agenda

Page 3: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Agenda

Overview of 3D Touch

Page 4: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Agenda

Overview of 3D TouchHome Screen Quick Actions

Page 5: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Agenda

Overview of 3D TouchHome Screen Quick ActionsPeek and Pop

Page 6: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Agenda

Overview of 3D TouchHome Screen Quick ActionsPeek and PopUIPreviewInteraction

NEW

Page 7: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Tour across the systemOverview of 3D Touch

Page 8: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 9: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 10: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 11: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 12: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 13: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 14: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 15: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 16: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 17: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 18: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 19: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Supporting 3D Touch

Page 20: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Supporting 3D Touch

Accelerate access to existing features in your app

Page 21: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Supporting 3D Touch

Accelerate access to existing features in your appEnable new immersive interactions

Page 22: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Supporting 3D Touch

Accelerate access to existing features in your appEnable new immersive interactionsProvide a consistent experience across iOS

Page 23: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Leap straight into action from the home screenHome Screen Quick Actions

Page 24: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 25: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 26: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 27: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 28: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 29: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 30: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Home Screen Quick Actions

StaticDynamic

Two types

Page 31: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Home Screen Quick ActionsStatic

Page 32: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Home Screen Quick Actions

Defined in your app’s Info.plist

Static

Page 33: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Home Screen Quick Actions

Defined in your app’s Info.plistAvailable as soon as your app has been installed

Static

Page 34: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Home Screen Quick Actions

Defined in your app’s Info.plistAvailable as soon as your app has been installed

Static

Page 35: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

DynamicHome Screen Quick Actions

Page 36: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

DynamicHome Screen Quick Actions

Created by your app at runtime

Page 37: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

DynamicHome Screen Quick Actions

Created by your app at runtimeAvailable after the first launch of your app

Page 38: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

DynamicHome Screen Quick Actions

Created by your app at runtimeAvailable after the first launch of your appShown after any static quick actions (space permitting)

Page 39: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

DynamicHome Screen Quick Actions

Created by your app at runtimeAvailable after the first launch of your appShown after any static quick actions (space permitting)Can include a system icon, custom icon, or Address Book contact

Page 40: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Using a contact for the iconDynamic Quick Actions

let contactName = "Lexi Torres"

var contactIcon: UIApplicationShortcutIcon? = nil

Page 41: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Using a contact for the iconDynamic Quick Actions

let contactName = "Lexi Torres"

var contactIcon: UIApplicationShortcutIcon? = nil

// Make sure to request access to the user's contacts first

if CNContactStore.authorizationStatus(for: .contacts) == .authorized {

}

Page 42: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Using a contact for the iconDynamic Quick Actions

let contactName = "Lexi Torres"

var contactIcon: UIApplicationShortcutIcon? = nil

// Make sure to request access to the user's contacts first

if CNContactStore.authorizationStatus(for: .contacts) == .authorized {

let predicate = CNContact.predicateForContacts(matchingName: contactName)

let contacts = try? CNContactStore().unifiedContacts(matching: predicate, keysToFetch: [])

}

Page 43: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Using a contact for the iconDynamic Quick Actions

let contactName = "Lexi Torres"

var contactIcon: UIApplicationShortcutIcon? = nil

// Make sure to request access to the user's contacts first

if CNContactStore.authorizationStatus(for: .contacts) == .authorized {

let predicate = CNContact.predicateForContacts(matchingName: contactName)

let contacts = try? CNContactStore().unifiedContacts(matching: predicate, keysToFetch: [])

if let contact = contacts?.first {

contactIcon = UIApplicationShortcutIcon(contact: contact)

}

}

Page 44: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Using a contact for the iconDynamic Quick Actions

let contactName = "Lexi Torres"

var contactIcon: UIApplicationShortcutIcon? = nil

// Make sure to request access to the user's contacts first

if CNContactStore.authorizationStatus(for: .contacts) == .authorized {

let predicate = CNContact.predicateForContacts(matchingName: contactName)

let contacts = try? CNContactStore().unifiedContacts(matching: predicate, keysToFetch: [])

if let contact = contacts?.first {

contactIcon = UIApplicationShortcutIcon(contact: contact)

}

}

let icon = contactIcon ?? UIApplicationShortcutIcon(type: .message)

let contactName = "Lexi Torres"

var contactIcon: UIApplicationShortcutIcon? = nil

// Make sure to request access to the user's contacts first

if CNContactStore.authorizationStatus(for: .contacts) == .authorized {

let predicate = CNContact.predicateForContacts(matchingName: contactName)

let contacts = try? CNContactStore().unifiedContacts(matching: predicate, keysToFetch: [])

if let contact = contacts?.first {

contactIcon = UIApplicationShortcutIcon(contact: contact)

}

}

let icon = contactIcon ?? UIApplicationShortcutIcon(type: .message)

Page 45: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Creating and registeringDynamic Quick Actions

// Create a dynamic quick action using the icon

let type = "com.company.app.sendChatTo"

let subtitle = "Send a chat"

let shortcutItem1 = UIApplicationShortcutItem(type: type, localizedTitle: contactName,

localizedSubtitle: subtitle, icon: icon)

Page 46: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Creating and registeringDynamic Quick Actions

// Create a dynamic quick action using the icon

let type = "com.company.app.sendChatTo"

let subtitle = "Send a chat"

let shortcutItem1 = UIApplicationShortcutItem(type: type, localizedTitle: contactName,

localizedSubtitle: subtitle, icon: icon)

// Repeat as needed for any additional dynamic quick actions...

Page 47: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Creating and registeringDynamic Quick Actions

// Create a dynamic quick action using the icon

let type = "com.company.app.sendChatTo"

let subtitle = "Send a chat"

let shortcutItem1 = UIApplicationShortcutItem(type: type, localizedTitle: contactName,

localizedSubtitle: subtitle, icon: icon)

// Repeat as needed for any additional dynamic quick actions...

let shortcutItems = [shortcutItem1, shortcutItem2, shortcutItem3]

Page 48: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Creating and registeringDynamic Quick Actions

// Create a dynamic quick action using the icon

let type = "com.company.app.sendChatTo"

let subtitle = "Send a chat"

let shortcutItem1 = UIApplicationShortcutItem(type: type, localizedTitle: contactName,

localizedSubtitle: subtitle, icon: icon)

// Repeat as needed for any additional dynamic quick actions...

let shortcutItems = [shortcutItem1, shortcutItem2, shortcutItem3]

// Register the dynamic quick actions to display on the home screen

application.shortcutItems = shortcutItems

Page 49: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

647 x 1150

Page 50: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

On app activationHandling Quick Actions

func application(application: UIApplication,

performActionForShortcutItem shortcutItem: UIApplicationShortcutItem,

completionHandler: Bool -> Void) {

}

Page 51: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

On app activationHandling Quick Actions

func application(application: UIApplication,

performActionForShortcutItem shortcutItem: UIApplicationShortcutItem,

completionHandler: Bool -> Void) {

let didHandle: Bool = /* handle the quick action using shortcutItem */

completionHandler(didHandle)

}

Page 52: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

On app activationHandling Quick Actions

func application(application: UIApplication,

performActionForShortcutItem shortcutItem: UIApplicationShortcutItem,

completionHandler: Bool -> Void) {

let didHandle: Bool = /* handle the quick action using shortcutItem */

completionHandler(didHandle)

}

Page 53: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

On app launchHandling Quick Actions

func application(application: UIApplication,

didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

}

Page 54: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

On app launchHandling Quick Actions

func application(application: UIApplication,

didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

var performAdditionalHandling = true

if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey]

as? UIApplicationShortcutItem {

/* handle the quick action using shortcutItem */

performAdditionalHandling = false

}

return performAdditionalHandling

}

Page 55: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

On app launchHandling Quick Actions

func application(application: UIApplication,

didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

var performAdditionalHandling = true

if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey]

as? UIApplicationShortcutItem {

/* handle the quick action using shortcutItem */

performAdditionalHandling = false

}

return performAdditionalHandling

}

Page 56: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

On app launchHandling Quick Actions

func application(application: UIApplication,

didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

var performAdditionalHandling = true

if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey]

as? UIApplicationShortcutItem {

/* handle the quick action using shortcutItem */

performAdditionalHandling = false

}

return performAdditionalHandling

}

Page 57: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesHome Screen Quick Actions

Page 58: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesHome Screen Quick Actions

Every app should provide quick actions

Page 59: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesHome Screen Quick Actions

Every app should provide quick actionsFocus on providing quick access to high-value tasks

Page 60: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesHome Screen Quick Actions

Every app should provide quick actionsFocus on providing quick access to high-value tasksMake quick actions predictable

Page 61: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesHome Screen Quick Actions

Every app should provide quick actionsFocus on providing quick access to high-value tasksMake quick actions predictableBe prepared to handle dynamic quick actions from a previous version of your app

Page 62: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesHome Screen Quick Actions

Every app should provide quick actionsFocus on providing quick access to high-value tasksMake quick actions predictableBe prepared to handle dynamic quick actions from a previous version of your appDon’t add functionality that is only accessible using quick actions

Page 63: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Peter Hajas UIKit Frameworks Engineer

Peek and PopSeamlessly preview and navigate to content

Page 64: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 65: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 66: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 67: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 68: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 69: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Preview

Page 70: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 71: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 72: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Commit

Page 73: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Adding Peek and Pop to Your AppComponents of the interaction

Page 74: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Adding Peek and Pop to Your App

Registered View Controller

Components of the interaction

Page 75: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Adding Peek and Pop to Your App

Registered View Controller

Source

Registered View Controller

Components of the interaction

Page 76: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Adding Peek and Pop to Your App

Registered View Controller Previewed View Controller

Source

Registered View Controller

Source

Components of the interaction

Page 77: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Adding Peek and Pop to Your App

Registered View Controller Previewed View Controller

Source

Components of the interaction

Page 78: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Conforming to UIViewControllerPreviewingDelegateAdding Peek and Pop to Your App

class ChatTableViewController : UITableViewController,

UIViewControllerPreviewingDelegate

Page 79: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Conforming to UIViewControllerPreviewingDelegateAdding Peek and Pop to Your App

class ChatTableViewController : UITableViewController,

UIViewControllerPreviewingDelegate

Page 80: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Registering for previewingAdding Peek and Pop to Your App

override func viewDidLoad() {

super.viewDidLoad()

registerForPreviewing(with: self, sourceView: tableView)

}

Page 81: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Registering for previewingAdding Peek and Pop to Your App

override func viewDidLoad() {

super.viewDidLoad()

registerForPreviewing(with: self, sourceView: tableView)

}

Page 82: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Registering for previewingAdding Peek and Pop to Your App

override func viewDidLoad() {

super.viewDidLoad()

registerForPreviewing(with: self, sourceView: tableView)

}

Page 83: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Providing a preview view controllerAdding Peek and Pop to Your App

func previewingContext(_ previewingContext: UIViewControllerPreviewing,

viewControllerForLocation location: CGPoint) -> UIViewController? {

}

Page 84: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Providing a preview view controllerAdding Peek and Pop to Your App

func previewingContext(_ previewingContext: UIViewControllerPreviewing,

viewControllerForLocation location: CGPoint) -> UIViewController? {

}

Page 85: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewingContext(_ previewingContext: UIViewControllerPreviewing,

viewControllerForLocation location: CGPoint) -> UIViewController? {

guard let indexPath = tableView.indexPathForRow(at: location) else { return nil }

}

Providing a preview view controllerAdding Peek and Pop to Your App

Page 86: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewingContext(_ previewingContext: UIViewControllerPreviewing,

viewControllerForLocation location: CGPoint) -> UIViewController? {

guard let indexPath = tableView.indexPathForRow(at: location) else { return nil }

let chatDetailViewController = ...

chatDetailViewController.chatItem = chatItem(at: indexPath)

}

Providing a preview view controllerAdding Peek and Pop to Your App

Page 87: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewingContext(_ previewingContext: UIViewControllerPreviewing,

viewControllerForLocation location: CGPoint) -> UIViewController? {

guard let indexPath = tableView.indexPathForRow(at: location) else { return nil }

let chatDetailViewController = ...

chatDetailViewController.chatItem = chatItem(at: indexPath)

let cellRect = tableView.rectForRow(at: indexPath)

let sourceRect = previewingContext.sourceView.convert(cellRect, from: tableView)

previewingContext.sourceRect = sourceRect

}

Providing a preview view controllerAdding Peek and Pop to Your App

Page 88: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewingContext(_ previewingContext: UIViewControllerPreviewing,

viewControllerForLocation location: CGPoint) -> UIViewController? {

guard let indexPath = tableView.indexPathForRow(at: location) else { return nil }

let chatDetailViewController = ...

chatDetailViewController.chatItem = chatItem(at: indexPath)

let cellRect = tableView.rectForRow(at: indexPath)

let sourceRect = previewingContext.sourceView.convert(cellRect, from: tableView)

previewingContext.sourceRect = sourceRect

return chatDetailViewController

}

Providing a preview view controllerAdding Peek and Pop to Your App

Page 89: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 90: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 91: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Committing a preview view controllerAdding Peek and Pop to Your App

func previewingContext(_ previewingContext: UIViewControllerPreviewing,

commit viewControllerToCommit: UIViewController) {

show(viewControllerToCommit, sender: self)

}

Page 92: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Committing a preview view controllerAdding Peek and Pop to Your App

func previewingContext(_ previewingContext: UIViewControllerPreviewing,

commit viewControllerToCommit: UIViewController) {

show(viewControllerToCommit, sender: self)

}

Page 93: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Committing a preview view controllerAdding Peek and Pop to Your App

func previewingContext(_ previewingContext: UIViewControllerPreviewing,

commit viewControllerToCommit: UIViewController) {

show(viewControllerToCommit, sender: self)

}

Page 94: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 95: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 96: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 97: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 98: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Preview quick actions

Registered View Controller Previewed View Controller

Source

Peek and Pop

Page 99: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

override func previewActionItems() -> [UIPreviewActionItem] {

let heart = UIPreviewAction(title: "❤", style: .default) { (action, viewController) in

// Send a heart

}

return [heart]

}

Preview quick actionsAdding Peek and Pop to Your App

Page 100: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

override func previewActionItems() -> [UIPreviewActionItem] {

let heart = UIPreviewAction(title: "❤", style: .default) { (action, viewController) in

// Send a heart

}

return [heart]

}

Preview quick actionsAdding Peek and Pop to Your App

Page 101: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

let replyActions = [UIPreviewAction(title: "❤", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😄", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "👍", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😯", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😢", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😈", style: .default, handler: replyActionHandler)]

let sendReply = UIPreviewActionGroup(title: "Send Reply…",

style: .default,

actions: replyActions)

Preview quick action groupsAdding Peek and Pop to Your App

Page 102: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

let replyActions = [UIPreviewAction(title: "❤", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😄", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "👍", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😯", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😢", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😈", style: .default, handler: replyActionHandler)]

let sendReply = UIPreviewActionGroup(title: "Send Reply…",

style: .default,

actions: replyActions)

Preview quick action groupsAdding Peek and Pop to Your App

Page 103: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

let replyActions = [UIPreviewAction(title: "❤", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😄", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "👍", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😯", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😢", style: .default, handler: replyActionHandler),

UIPreviewAction(title: "😈", style: .default, handler: replyActionHandler)]

let sendReply = UIPreviewActionGroup(title: "Send Reply…",

style: .default,

actions: replyActions)

Preview quick action groupsAdding Peek and Pop to Your App

Page 104: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Other preview quick action stylesAdding Peek and Pop to Your App

let save = UIPreviewAction(title: "Chat Saved", style: .selected, handler: saveHandler)

let block = UIPreviewAction(title: "Block", style: .destructive, handler: blockHandler)

Page 105: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesPeek and Pop

Page 106: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesPeek and Pop

Content that can be tapped should support Peek and Pop

Page 107: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesPeek and Pop

Content that can be tapped should support Peek and PopReturn a preview view controller consistently

Page 108: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesPeek and Pop

Content that can be tapped should support Peek and PopReturn a preview view controller consistentlyDon’t take too long in the previewing delegate

Page 109: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Best practicesPeek and Pop

Content that can be tapped should support Peek and PopReturn a preview view controller consistentlyDon’t take too long in the previewing delegateSet the previewing context sourceRect

Page 110: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Peek and Pop feel with your user interfaceUIPreviewInteraction

NEW

Page 111: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 112: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 113: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 114: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 115: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 116: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 117: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 118: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 119: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 120: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 121: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 122: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide
Page 123: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Same Peek and Pop Force Processing

Automatic Haptic Feedback Your User Interface

UIPreviewInteraction

+ +

Page 124: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

extension ChatDetailViewController : UIPreviewInteractionDelegate

UIPreviewInteractionDelegateUIPreviewInteraction

Page 125: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

override func viewDidLoad() {

super.viewDidLoad()

replyPreviewInteraction = UIPreviewInteraction(view: view)

replyPreviewInteraction.delegate = self

}

Creating the UIPreviewInteractionUIPreviewInteraction

Page 126: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

override func viewDidLoad() {

super.viewDidLoad()

replyPreviewInteraction = UIPreviewInteraction(view: view)

replyPreviewInteraction.delegate = self

}

Creating the UIPreviewInteractionUIPreviewInteraction

Page 127: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Starting the interactionUIPreviewInteraction

previewInteractionShouldBegin()previewInteractionShouldBegin()

Preview

Page 128: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

Preview

Page 129: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

Preview

Page 130: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

0.200.400.60

0.80

Preview

Page 131: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

0.10

Preview

Page 132: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

0.20

State transitionsUIPreviewInteraction

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

0.40

0.600.80

1.00Preview

Page 133: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewInteraction(_ previewInteraction: UIPreviewInteraction,

didUpdatePreviewTransition transitionProgress: CGFloat,

ended: Bool) {

updateForPreview(progress: transitionProgress)

if ended {

completePreview()

}

}

Preview transitionUIPreviewInteraction

Page 134: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewInteraction(_ previewInteraction: UIPreviewInteraction,

didUpdatePreviewTransition transitionProgress: CGFloat,

ended: Bool) {

updateForPreview(progress: transitionProgress)

if ended {

completePreview()

}

}

Preview transitionUIPreviewInteraction

Page 135: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewInteraction(_ previewInteraction: UIPreviewInteraction,

didUpdatePreviewTransition transitionProgress: CGFloat,

ended: Bool) {

updateForPreview(progress: transitionProgress)

if ended {

completePreview()

}

}

Preview transitionUIPreviewInteraction

Page 136: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewInteractionDidCancel(_ previewInteraction: UIPreviewInteraction) {

UIView.animate(withDuration: 0.4) {

self.updateForPreview(progress: 0)

self.resetToInitialAppearance()

}

}

CancellationUIPreviewInteraction

Page 137: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewInteractionDidCancel(_ previewInteraction: UIPreviewInteraction) {

UIView.animate(withDuration: 0.4) {

self.updateForPreview(progress: 0)

self.resetToInitialAppearance()

}

}

CancellationUIPreviewInteraction

Page 138: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

Preview

Page 139: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdateCommitTransition:ended:)

Preview

Commit

Page 140: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

0.200.400.600.80

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdateCommitTransition:ended:)

Preview

Commit

Page 141: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

0.10previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdateCommitTransition:ended:)

Preview

Commit

Page 142: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

0.200.400.600.801.00

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdateCommitTransition:ended:)

Preview

Commit

Page 143: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

0.200.400.600.801.00

0.200.400.600.80

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdateCommitTransition:ended:)

Preview

Commit

Page 144: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

0.200.400.600.801.00

0.10

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdateCommitTransition:ended:)

Preview

Commit

Page 145: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

State transitionsUIPreviewInteraction

0.200.400.600.801.00

0.200.400.600.801.00

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdatePreviewTransition:ended:)

previewInteraction(didUpdatePreviewTransition:ended:)previewInteraction(didUpdateCommitTransition:ended:)

Preview

Commit

Page 146: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewInteraction(_ previewInteraction: UIPreviewInteraction,

didUpdateCommitTransition transitionProgress: CGFloat,

ended: Bool) {

updateForCommit(progress: transitionProgress)

if ended {

completeCommit()

}

}

Commit transitionUIPreviewInteraction

Page 147: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewInteraction(_ previewInteraction: UIPreviewInteraction,

didUpdateCommitTransition transitionProgress: CGFloat,

ended: Bool) {

updateForCommit(progress: transitionProgress)

if ended {

completeCommit()

}

}

Commit transitionUIPreviewInteraction

Page 148: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

func previewInteraction(_ previewInteraction: UIPreviewInteraction,

didUpdateCommitTransition transitionProgress: CGFloat,

ended: Bool) {

updateForCommit(progress: transitionProgress)

if ended {

completeCommit()

}

}

Commit transitionUIPreviewInteraction

Page 149: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Low-Level Force API

Page 150: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Low-Level Force API

Normalized access to force data

Page 151: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

force maximumPossibleForce

Low-Level Force API

Normalized access to force dataProperties on UITouch: force and maximumPossibleForce

Page 152: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

force maximumPossibleForce

Low-Level Force API

Normalized access to force dataProperties on UITouch: force and maximumPossibleForceAvailable on devices that support 3D Touch or Apple Pencil

Page 153: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

force maximumPossibleForce

Low-Level Force API

Normalized access to force dataProperties on UITouch: force and maximumPossibleForceAvailable on devices that support 3D Touch or Apple Pencil

Leveraging Touch Input on iOS Pacific Heights Thursday 10:00AM

Page 154: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Summary

Page 155: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Summary

Home screen quick actions let you jump straight into action

Page 156: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Summary

Home screen quick actions let you jump straight into actionPeek and Pop allow you to quickly preview and navigate to content

Page 157: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Summary

Home screen quick actions let you jump straight into actionPeek and Pop allow you to quickly preview and navigate to contentUIPreviewInteraction opens up new possibilities to make your app more immersive

Page 158: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Summary

Home screen quick actions let you jump straight into actionPeek and Pop allow you to quickly preview and navigate to contentUIPreviewInteraction opens up new possibilities to make your app more immersiveUsers expect your apps to support 3D Touch

Page 159: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

More Information

https://developer.apple.com/wwdc16/228

Page 160: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Related Sessions

Advances in UIKit Animations and Transitions Pacific Heights Wednesday 5:00PM

Leveraging Touch Input on iOS Pacific Heights Thursday 10:00AM

Page 161: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide

Labs

Cocoa Touch and 3D Touch Lab Frameworks Lab C Friday 10:30AM

Page 162: 228 A Peek at 3D Touch 03 A FINAL › videos › wwdc › 2016 › 228a...Supporting 3D Touch Accelerate access to existing features in your app Enable new immersive interactions Provide