I want to find the pressure of the touch. I just don't know how to accomplish that result with out jailbreaking it and getting the raw touch data. Does anyone know How I would do this?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Can not export audiofiles via “open in:” from Voic
- XCode 4.5 giving me “SenTestingKit/SenTestKit.h” f
In iOS 3.2 and 4.0 you can get the value more directly like this:
Still not App Store approved, but handy for custom stuff.
You cannot get the pressure from the SDK nor undocumented methods. However you can detect the size of touch with undocumented methods.
In the GSEvent, which is a lower-level representation of UIEvent, there is a structure known as GSPathInfo with members:
We notice that there is a
pathPressure
andpathMajorRadius
. I can assure you the pressure member is useless – it always gives 0. HoweverpathMajorRadius
does contain meaningful information – it gives the major radius of the touch in millimeters. You can therefore give an extremely rough estimation if it's a heavy touch or light touch from the radius.Let me warn you again this is undocumented and you should not use it in AppStore apps.
Edit: On 3.2 and above the
pathMajorRadius
of a GSPathInfo is also available as an undocumented property in UITouch:so the code above could be rewritten using pure Objective-C:
As of iOS 8.0,
UITouch
has a publicmajorRadius
property which tells you the approximate size of the touch.It's not possible with the SDK. It does not expose that data in anyway. And the screen does not sense pressure, and wether it even reports touch "size" to the OS is unknown. So sadly, what you are trying to do is not possible on a legit application.
I know because I asked the same thing: Can the iPhone detect the size of a touch?