swift - 如何获取WKInterfaceTimer计数事件的句柄?

标签 swift watchkit

我想使用 WkInterfaceTimer 进行倒计时。 从 NSTiemer 开始,我想获取倒计时时发生的事件。

WkInterfaceTimer没有这样的Delegate,怎么办?

最佳答案

WKInterfaceTimer 的文档解释得很好:

A WKInterfaceTimer object is a special type of label that displays a countdown or count-up timer. ... To know when the timer reaches 0, configure an NSTimer object with the same target date you used to set up the timer.

基本上,在 watch 上使用 NSTimer 的方式与在 iOS 应用程序中使用的方式相同,只需使用 WKInterfaceTimer 作为在 watch 屏幕上显示倒计时的方式即可。

关于swift - 如何获取WKInterfaceTimer计数事件的句柄?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40033263/

相关文章:

ios - 从我的应用程序获取坐标到 Uber(ios、swift4)

swift - WatchKit:reloadRootControllers 没有删除 Controller (对象仍然存在,我希望它被销毁)

ios - 在 didReceiveUserInfo 之前调用 TableView 设置

Swift - 使用参数获取枚举中的大小写和值

arrays - 基于另一个数组快速排序数组

swift - 返回完成 block 内方法的对象

swift - 在 WatchKit 上从 URL 加载图像

ios - 我可以让我的 WatchKit 应用程序在 Apple Watch 的后台运行吗?

ios - 如何从 iOS app 显示 watchkit glance

swift - 从 NSViewController 访问 AppDelegate 方法