首页 > 解决方案 > AppleWatch:Digital Crown 触觉反馈

问题描述

我正在构建WathcOS 应用程序。有一个只有标签的简单视图。当用户滚动 Digital Crown 时,我想更改标签文本。

在我的 WKInterfaceController 我做了

crownSequencer.delegate = self
crownSequencer.focus()

func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {
    crownAccumulator += rotationalDelta
    var crowAccumulatorDelta = 0.05
    if let speed = crownSequencer?.rotationsPerSecond {
        crowAccumulatorDelta = speed < 0.5 ? 0.05 : 0.01
    }

    if crownAccumulator > crowAccumulatorDelta {
        crownAccumulator = 0.0
        updateDistanceValue(distance + 0.1)
    } else if crownAccumulator < -crowAccumulatorDelta {
        crownAccumulator = 0.0
        updateDistanceValue(distance - 0.1)
    }
}

问题是我没有听到 Native Digital Crown Haptic 反馈,例如当您在 Watch Home 屏幕或任何其他应用程序上滚动它时。我可以手动添加触觉反馈,例如:WKInterfaceDevice.current().play(.click) 但这与 Scroll 触觉不同。如何打开滚动触觉?为什么它不起作用?

PS Haptic 在手表设置中打开。

标签: iosswiftwatchoswatchos-5

解决方案


如果有人遇到同样的问题:无需在代码中做某事。它默认工作。为了使它起作用,手表设置的音量不应该是最小的。


推荐阅读