Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if 3D touch is supported and enabled on the iOS9 device

I tried to access the trait collection and check "forceTouchCapability", but "forceTouchCapability" simply checks to see if the device is iOS 9.0 or greater.

So, this means that on any device with iOS 9, force touch is 'available'. I need to a way to check if 3D touch is actually supported on the users device (iPhone 6s) and I need to make sure that the 3D Touch option is actually enabled in the accessibility settings.

like image 901
Prodigga Avatar asked Sep 28 '15 00:09

Prodigga


People also ask

How do I know if 3D Touch is working?

If your phone supports 3D Touch but it's not working, it could simply be turned off. Go to Settings > General > Accessibility > 3D Touch to check.

What is iPhone 3D Touch?

Apple 3D Touch is a hardware-based feature Apple introduced in iPhone 6s and 6s Plus devices running iOS 9 that perceives the amount of force a user puts on the touch screen to activate different functions. With Apple 3D Touch, users can take actions without navigating away from the original screen they were on.


1 Answers

I was accidentally casting forceTouchCapability to a BOOL (using it as a return value to my method that was set to return a boolean). I needed to check if forceTouchCapability was equal to UIForceTouchCapabilityAvailable.

Instead of:

return [[MyView traitCollection] forceTouchCapability];

I need:

return [[MyView traitCollection] forceTouchCapability] == UIForceTouchCapabilityAvailable;
like image 142
Prodigga Avatar answered Nov 16 '22 00:11

Prodigga