在哪里可以找到 watchOS 2 的 Taptic 反馈 API 文档或功能? [英] Where to find Taptic feedback API documentation or capabilities for watchOS 2?

查看:29
本文介绍了在哪里可以找到 watchOS 2 的 Taptic 反馈 API 文档或功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣使用触觉反馈为 watchOS 2 构建应用程序.目前我没有 Apple Watch,但我可以访问 Apple Developer Program.我试过查看 watchOS Developer LibrarywatchOS 2 发行说明.

I'm interested in building an app for watchOS 2 using haptic feedback. Currently I do not have the Apple Watch, but I have access to the Apple Developer Program. I've tried looking at the watchOS Developer Library and watchOS 2 Release Notes.

我没有看到任何提及如何以编程方式访问 Taptic 引擎或它在当前 watchOS 2 中的功能.

I do not see any mention of how to access the Taptic engine programmatically or what it is capable of in the current watchOS 2.

我如何以编程方式访问 Taptic 引擎或了解新的 Taptic API 能够做什么?

How can I access the Taptic engine programmatically or understand what the new Taptic API is capable of doing?

推荐答案

您可以在此处找到有关触觉反馈的 Apple API 文档:

You can find the Apple API documentations for the haptic feedback here:

https://developer.apple.com/documentation/watchkit/wkinterfacedevice

你会发现一个名为

- playHaptic:

所以你需要调用这个函数来播放相关的触觉.这可以通过以下代码完成:

So you need to call this function to play the related haptic. This can be done with the following code:

斯威夫特:

WKInterfaceDevice.currentDevice().playHaptic(<#WKHapticType#>)

目标-C:

[[WKInterfaceDevice currentDevice] playHaptic:<#WKHapticType#>]

但请注意,目前这些反馈无法在模拟器上进行测试(因为这些触觉反馈是由新的 Taptic Engine 产生的,除了真正的 Apple Watch 之外,其他任何设备都无法访问该引擎),但您可以对其进行测试如果您有一台真实设备(安装了 watchOS 2 测试版).

Be aware though, for now these feedbacks are unavailable to test on the simulator (because these haptic feedbacks are produced by the new Taptic Engine which is not accessible from any other device than a real Apple Watch), but you can test it on a real device (with watchOS 2 beta installed) if you have one.

这些是您可以播放的触觉类型:

These are the types of haptic you can play:

   WKHapticType.Notification,
   WKHapticType.DirectionUp,
   WKHapticType.DirectionDown,
   WKHapticType.Success,
   WKHapticType.Failure,
   WKHapticType.Retry,
   WKHapticType.Start,
   WKHapticType.Stop,
   WKHapticType.Click 

这篇关于在哪里可以找到 watchOS 2 的 Taptic 反馈 API 文档或功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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