问题描述
在我的应用程序中,我将显示设置,只有设备可以进行3D触摸时,该设置才应该可见.目前,我检查设备是否具有ios9.
In my app I will show settings, which only should be visible, if the device can 3D Touch. at the moment I check, if the device has ios9.
if #available(iOS 9.0, *)
问题是例如iPhone 6具有iOS 9但没有3D Touch.如何快速检查3D Touch的可能性?
problem is, for example the iPhone 6 have iOS 9 but no 3D Touch. how can I check the possibility of 3D Touch with swift?
我找到了这篇文章,但没有快速解决方案:>是否支持和启用3D touch在iOS9设备上
i found this post, but no swift solution:Check if 3D touch is supported and enabled on the iOS9 device
另一个问题.现在,我想检查iOS 9 AND 3D Touch是否可用.我试试这个:
One more Question.now i want to check if iOS 9 AND 3D Touch is available.i try this:
if (#available(iOS 9.0, *)) AND (is3DTouchAvailable() == true) {
但是我总是会收到此错误:
But i always get this error:
推荐答案
尝试一下此快速代码, self
指的是您的 UIViewController
Try this swift code, self
is referring to your UIViewController
func is3DTouchAvailable() -> Bool
{
return self.traitCollection.forceTouchCapability == UIForceTouchCapability.Available
}
这篇关于快速检查是否可以使用3D Touch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!