One of Apple’s newest hardware features, 3D Touch, is a useful add-on for most apps including ours. It allows iPhone 6s/6s Plus users to “peek” into views. I imagine it is beneficial to a wide variety of applications, and luckily it is really easy to add into your existing apps! I use storyboards when developing MySwimPro for iOS, so I’ll quickly walk through how easy it is to implement 3D Touch. We’ll go through the two most popular use cases: quick actions and peek and pop presentations.
Related: What It’s Like To Be On The Home Page of the App Store
Quick actions are ways for your users to quickly get to parts of your app that are most-used or are convenient for quick access. Apps can have static or dynamic actions. Static actions link users to specific screens in your app, like a profile page. Dynamic actions link users to a screen that may change, like the last few people you texted in the Messages app.
MySwimPro has a static quick action that links athletes to the “New Workout” screen. Creating a static action is easy: just add a dictionary containing the icon, text, and id of where you want to go to the `UIApplicationShortcutItems` array in your app’s Info.plist file. The dictionary will look something like this:
<string>Create New Workout</string>
The `UIApplicationShortcutItemType` tells the app where to open to. It gets significantly more hairy from here: you have to handle the Type in your ApplicationDelegate on open. I’ll defer you Apple’s documentation – they have some great sample code for handling app opens from quick actions.
Peek and Pop
You’ll want to do some human centered design to determine where it makes sense to put peek and pop transitions in your app. It’s best implemented in places where the user is unsure if they want to fully enter a screen – like browsing pictures, emails, or… workouts!
We have peek and pop segues available when athletes browse workouts, so if someone wants a preview of a workout, they can “peek” into it. If it looks good, they “pop” it into full-screen. This is super super easy to implement in storyboards, like this:
Just tick the “Peek & Pop” box when selecting the segue between the two views you’re connecting. Granted, there are some caveats. For one, peeking on a view controller will reveal any autolayout issues you have if they are based on the presenting view controller or layout guides. You will also quickly realize any lifecycle issues your view controller has: code in viewDidAppear that should be in viewDidLoad, for example.
Related: 5 Things I’m Excited About From WWDC
I love seeing how apps implement new features to get the most out of the platform. We have some exciting new things in the works for iOS 10! 😎
If you have any ideas or questions feel free to contact me at firstname.lastname@example.org.