Introduction to 3D Touch

Introduction

  • With iOS 9, new iPhone models add a third dimension to the user interface.
  • A user can now press your Home screen icon to immediately access functionality provided by your app.
  • Within your app, a user can now press views to see previews of additional content and gain accelerated access to features.
  • Apple’s own apps mostly use 3D Touch for getting a little preview of the next thing you want to do. So if you’re on the home screen, hard press on an icon to get a few shortcuts directly into a section of the app.
  • If you want to your app more interactive to add 3D touch in your application
  • Two major 3D touch features need to add your app.
    1. Peek and Pop
    2. Quick Actions

1. Implement Peek and Pop :

A. Storyboard -> Using Segue : (On cell Selection)

– create simple list screen as per your requirement. I already created below screen that contain tableview with simple cell
set-segue

-make sure your segue type is cell selection
cell selection

1. ListVC.swift

2. ListCell.swift

3. DetailVC.swift

peek-and-pop

2.Implement Quick Action:

– Create a UIApplicationShortcutItems array. This is where we define what the actions are, the title, subtitle, and shortcut keys, icon, dictionary. Note that you can only have a max of 4 quick actions off the icon in your app.

A. Dynamic Quick Action

type: A required string delivered to your app when the user invokes the corresponding quick action.
localizedTitle: A required string displayed to the user on the Home screen as the name of the quick action.
localizedSubtitle: An optional string that is displayed to the user on the Home screen, immediately below the corresponding title string. icon: An optional string specifying the type of an icon from the system-provided API. Full list of the icons https://developer.apple.com/reference/uikit/uiapplicationshortcuticontype. We can also set a custom icon. userInfo: An optional, app-defined dictionary.

1. AppDelegate.swift

– When user tap on any quick action below method will call. You can navigate specific screen as per your requirement.

Quick Action Output:

quick-action

A. Static Quick Action (Info.plist)
– home screen quick actions using the UIApplicationShortcutItems array in the app Info.plist file

1. Info.plist :
plist-screenshot

– add this key into you info.plist file

mm

Yogesh Makwana iOS Developer

I am an iOS developer at Yudiz Solutions Pvt. Ltd. - a leading iPhone App development company. My life motto is 'Do my best, so that I can't blame myself for anything.' I have a deep rooted obsession for developing creative iOS apps and different aspects.

Comments are closed.

Top