Tuesday, October 6, 2015

Developing With 3D Touch

Nick Keppol:

3D Touch also grew from constraints. Since it only works on the iPhone 6s and 6s Plus, Apple had to implement the feature in a way that adds value for those with the new devices, while not denying important actions from everyone else. This result is shortcuts—a new layer on top of an existing UI.

[…]

3D Touch on iOS 9 is well thought out and makes sense. For me, it takes this hardware feature from being a bit of a frustrating gimmick to something that has a great potential to provide a richer experience with well designed software. If Apple sticks with this shortcut layered approach I think 3D Touch with likely become one of those invisible features you’ll wonder how you ever lived without.

Ryan Nystrom:

Along with the new hardware, Apple added three APIs that let developers add another dimension of interaction to their apps. Quick Actions let you select up to four context menu items from your app’s icon. Another feature lets you “Peek” into content and then “Pop” deeper into it. The last API gives developers details about the depth of a UITouch with force and maximumPossibleForce.

[…]

The activity feed in Instagram contains both username tags and thumbnails that we wanted to peek. Each of the UIViewControllerPreviewingDelegate objects we built for profiles and media were built specifically for those views. We had to somehow combine the work being done in both delegates.

[…]

In some cases, when displaying a profile peek, we don’t have all the data we need in order to show latests photos or follower counts in the peek. Peek view controllers still receive viewDidLoad, viewWillAppear:, and other UIViewController events that we use to fetch network resources and update the view.

Dal Rupnik:

We’ve known about AVFoundation vibrate API’s for a while and they are still valid, but they do not interact with the Taptic Engine directly and only allow you to “play” vibrations. As Apple has demonstrated on iPhone 6s presentation, the Taptic Engine can create a much more subtle and elegant vibration, so we are mostly looking to reproduce that behaviour instead of using the normal vibrations.

Sadly, as it turns out that there is no public API to do this in iOS 9 and iOS 9.1 (but never say never).

[…]

Using private API’s may cause your application to be rejected on the App Store and should not be used in production, as it might change in the future. This post is a small research, because I am interested in how things work, not to get around Apple’s rules.

Update (2015-10-14): Keith Harrison:

To avoid handling the quick action twice we need to check in the willFinish… or didFinish… methods to see if we have a quick action, handle it and then return false. Returning false tells the system not to call performActionForShortcutItem.

Dan Moren:

That said, I think that 3D Touch is an awesome enhancement to iOS; I just wish that Apple had seen fit to use it in more places. In particular, I—and many of our readers, if my emails and Twitter replies are any indication—would love to see 3D Touch in use in iOS’s Control Center.

Update (2015-10-21): R. Kevin Nelson:

From my perspective, this means that I’m basically forced into looking at the first two touch values to calculate any kind of meaningful velocity, but depending on what you’re doing with 3D Touch, this quirk is worth being aware of: The first force is usually 0.00.

[…]

At extremely light force levels, I was mostly seeing the actual force value fluctuate between one of a few specific numbers. Yes, they are floating point, but they also exhibited extreme uniformity to the point that it was easy to hypothesize that the actual values were merely integers divided by a multiple-of-3 divisor. […] At this point, it seems pretty safe to say that the floating point value that Apple propagates to the developer interface is actually an integer between 0 and 400 that’s divided by 60 somewhere along the way.

[…]

So, it seems that at high pressures, the sensing mechanism is no longer linear with respect to touch location. Apple is apparently using pressures beyond the public API’s maximum for Peek and Pop, so it’s unclear where that breakdown in linearity happens. It won’t matter so much either way, though, since the _pressure value is private.

1 Comment RSS · Twitter

[…] iOS 9’s Quick Actions shortcut support in 15 minutes right now!; Lessons learned with 3D Touch; Developing With 3D Touch; Your 3D Touch Spirit Guide; Adding 3D Touch Quick Actions; Peek & Pop; 3D Touch Peek and Pop; […]

Leave a Comment