gpt4 book ai didi

ios - Apple 是否在 Swift 中弃用了 iPhone 3D touch?

转载 作者:行者123 更新时间:2023-11-28 19:24:59 25 4
gpt4 key购买 nike

我在 2 年前使用 Swift 中的 3D 触摸功能制作了一款游戏,因为它很新,但我从未发布过这款游戏,因为我获得了一份新契约(Contract)。现在我有时间想发布它,但代码不再有效。 (3D 触摸自定义操作,而不是 peek & pop 操作)

当我打印触摸结果时,力值将始终返回 0.0,如下所示:

[<UITouch: 0x102613850> phase: Began tap count: 2 force: 0.000 window: <UIWindow: 0x10222bf70; frame = (0 0; 414 896); gestureRecognizers = <NSArray: 0x28011cde0>; layer = <UIWindowLayer: 0x280f41840>> view: <UIView: 0x102083080; frame = (0 82; 414 780); autoresize = RM+BM; gestureRecognizers = <NSArray: 0x2801a0c30>; layer = <CALayer: 0x280f2a540>> location in window: {299.33332824707031, 661.66665649414062} previous location in window: {299.33332824707031, 661.66665649414062} location in view: {299.33332824707031, 579.66665649414062} previous location in view: {299.33332824707031, 579.66665649414062}]

我知道 Apple 出于成本原因正在从设备中删除此功能,但我记得,iPhone 11 pro 仍然具有此功能。有谁知道这个值是否被弃用?

最佳答案

Every touch starts as a contact with no force at all, as soon as the user's finger makes contact (or even near-contact) with the screen. The force only starts to build as the user's finger is compressed against the screen. UITouch force on touchesBegan is zero


Force Touch

The technology was first unveiled on September 9, 2014, during the introduction of Apple Watch. Starting with the Apple Watch, Force Touch has been incorporated into many products within Apple’s lineup. This notably includes MacBooks and the Magic Trackpad 2. The technology is known as 3D Touch on the iPhone models. source

这些设备支持触觉触控:

  • iPhone 11
  • iPhone 11 专业版
  • iPhone 11 专业版
  • iPhone XR

这些设备支持 3D Touch:

  • iPhone 6s
  • iPhone 6s Plus
  • iPhone 7
  • iPhone 7 Plus
  • iPhone 8
  • 苹果手机8 加
  • iPhone X
  • iPhone XS
  • iPhone XS Max

数据源(2020 年 1 月)Change 3D or Haptic Touch sensitivity on your iPhone

解决方案

检查设备上是否存在 3D Touch

if traitCollection.forceTouchCapability == .available {

}

The iOS trait environment is exposed though the traitCollection property of the UITraitEnvironment protocol. This protocol is adopted by the following classes: UIScreen, UIWindow, UIViewController, UIPresentationController, and UIView. source

关于ios - Apple 是否在 Swift 中弃用了 iPhone 3D touch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59821388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com