iOS9 3DTouch Tutorial: Introduction

Published Jan 08, 2016Last updated Feb 09, 2017
iOS9 3DTouch Tutorial: Introduction

Introduction

  • With iOS 9, new iPhone models add a third dimension to the user interface: 3DTouch.
  • A user can now press your app's Home screen icon to immediately access functionality provided by your app. (Ex: Open Chats page, Profile Page, or a Notification page in your Social App)
  • Within your app, a user can now press views to see previews of additional content and gain accelerated access to features. (Ex: Force on a UICollectoinViewCell to see details of any post in your Social App)

3DTouch Types

The Current API allows you to use three behaviours to make your app 3DTouch-enabled.

  1. Home Screen Quick Actions
  2. Peek and Pop
  3. TouchCanvas

1. Home Screen Quick Actions

By pressing an app icon from your 3DTouch-enabled device, the user will obtain a set of quick actions. When the user selects a quick action, your app activates or launches, and your app delegate object receives the quick action message.

There are two types of quick actions:

  • Static Quick Actions:
    Define static quick actions in your app’s Info.plist file in the UIApplicationShortcutItems array.
    UIApplicationShortcutItems can include Icon, Title, Subtitle,Type, and extra user info to show and use on QuickActions.
  • Dynamic Quick Actions: You can add dynamic quick actions with the UIApplicationShortcutItem class and its associated APIs. You can also add your dynamic quick actions to your app’s shared UIApplication object using the new shortcutItems property.

Notes:

  • Both types of quick actions can display up to two lines of text along with an optional icon.
  • You can add a maximum of 4 quick actions to your app

2. Peek and Pop

You can now enable the view controllers in your app (instances of the UIViewController class) to respond to user presses of various intensities. As the user presses more deeply, interaction proceeds through three phases:

Peek: Indication that content preview is available,
and display of the preview known as a peek (with options to act on it directly known as peek quick actions)

Pop: Optional navigation to the view shown in the preview known as a pop.

3. TouchCanvas

In iOS 9, the UITouch class has two new properties to support custom implementation of 3D Touch in your app: force and maximumPossibleForce.

For the first time on iOS devices, these properties let you detect and respond to touch pressure in the UIEvent objects your app receives.

Note: The force of a touch has a high dynamic range, available as a floating point value to your app.

Download samples provided by Apple

Download links:

Stay tuned for next 3DTouch practicals as well.

Discover and read more posts from Zaid Pathan
get started
Enjoy this post?

Leave a like and comment for Zaid

Be the first to share your opinion

Get curated posts in your inbox

Read more posts to become a better developer