ios - WatchKit/苹果 watch API : vibrations of custom length?

标签 ios watchkit

我在准备潜在的 iWatch 应用程序时有一个问题。之前没有编写 iOS 应用程序的经验,API 感觉非常令人生畏且难以导航。

这个项目的核心部分包括向 iWatch 发送振动脉冲——这完全可能吗,或者我是否仅限于标准的“通知”振动?如果是这样,是否知道发送振动通知的频率是多少?

我在 StackO 上找到了一个可能的相关主题: Are there APIs for custom vibrations in iOS? 这种方法适用于 iWatch 应用吗?

提前谢谢你。

最佳答案

目前,自定义 触觉反馈没有 API。但从 watchOS 2.0 开始,您可以通过提供 WKHapticType 选项来调用触觉反馈。

WKInterfaceDevice.current().play(.success)

这里是 WKHapticType 选项:

enum WKHapticType : Int {
    case Notification
    case DirectionUp
    case DirectionDown
    case Success
    case Failure
    case Retry
    case Start
    case Stop
    case Click
}

关于ios - WatchKit/苹果 watch API : vibrations of custom length?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27711983/

相关文章:

ios - 如何仅在 UILongPressGesture 之后启用 UIPanGestureRecognizer?

WatchKit 如何打电话

watchkit - 带有 SwiftUI 的 watchOS 中的全屏 View

ios - Watchkit 扩展中的 SwiftyJSON 不起作用

ios - captureImage.image;之间的区别和 [captureImage].image;

objective-c - 从后台调用应用程序时调用方法

ios - iOS 13 上的 AVAssetReferenceRestrictions

ios - 尝试将字符串数组传递给目标 View Controller

ios - WKInterfaceTable 中的部分

ios - handleWatchKitExtensionRequest 不响应 Watchkit 扩展中的 openParentApplication (Swift)