检查iOS9设备是否支持3D触控并启用 [英] Check if 3D touch is supported and enabled on the iOS9 device

查看:280
本文介绍了检查iOS9设备是否支持3D触控并启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试访问特征集合并检查forceTouchCapability,但forceTouchCapability只是检查设备是否为iOS 9.0或更高版本。

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.

因此,这意味着在iOS 9的任何设备上,强制触摸都是可用的。我需要一种方法来检查用户设备(iPhone 6s)是否实际支持3D触摸,我需要确保在辅助功能设置中实际启用了3D Touch选项。

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.

推荐答案

我不小心将 forceTouchCapability 投射到 BOOL (使用它作为我的方法的返回值,设置为返回布尔值)。我需要检查 forceTouchCapability 是否等于 UIForceTouchCapabilityAvailable

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.

而不是:

return [[MyView traitCollection] forceTouchCapability];

我需要:

return [[MyView traitCollection] forceTouchCapability] == UIForceTouchCapabilityAvailable;

这篇关于检查iOS9设备是否支持3D触控并启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆