7

I wonder if I can detect continuously changing pressure of user input on iPhone 6s.

With simple touch it's obvious, from the UIResponder you can hook into touchesBegan and TouchesMoved and you'll have the coordinates every time when the user touches the screen and when moves his/her finger, you can have the current position on every update.

However, I'm not sure how the new :force property works. If you read the "force" in touchesBegan, wouldn't you get some minimal pressure value that was detected at the initiation of the touch?

Is there a way to get update on the force value as it changes, just like the touchesMoved? Maybe there is a method like "forceChanged"?

mrtksn
  • 412
  • 3
  • 18
  • Did you try it? Most likely you get a new `touchesMoved:` event as the force changes. Write a simple test app and log the values and see what you get. – rmaddy Sep 22 '15 at 02:09
  • How to try it? The simulator doesn't support any way to simulate force for touch and the device is still not released :S – mrtksn Sep 22 '15 at 02:10
  • 1
    There are a few force-related menu options in the simulator that become active when you set the simulator to the iPhone 6s/6s+. – rmaddy Sep 22 '15 at 02:13
  • O.K, so how to simulate the force touch instead of normal touch? Currently it's returning 0.0 both for began and move – mrtksn Sep 22 '15 at 02:21
  • BTW, thanks for the suggestion but I suspect that the force touch settings in the simulator are for force touch, not 3d touch. It was worth trying though :) – mrtksn Sep 22 '15 at 02:31

1 Answers1

11

From the iOS 9.1 Release Notes

On 3D Touch capable devices, touch pressure changes cause touchesMoved: to be called.

Apps should be prepared to receive touch move events with no change in the x/y coordinates.

This means that a touchesMoved: callback either indicates a continuous change in force or location or both!

Hopefully this information will one day make it into the UITouch documentation.

Community
  • 1
  • 1
Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159