ios - 如何知道用户何时启动了 Apple Watch 应用程序?

标签 ios watchkit

我想知道用户何时启动我的 Apple Watch 应用程序(从菜单或复杂功能启动)。 WKInterfaceController的文档指出 didAppear当界面 Controller 内容出现在屏幕上时调用方法。

在我的simple example project我正在记录对 didAppear 方法的所有调用,我发现当应用程序在屏幕上不可见时也会调用它。

override func didAppear() {
   super.didAppear()
   log("didAppear") // Triggered when app not visible
}

我的猜测是这与快照刷新有关,但是有什么方法可以知道用户(而不是系统)何时启动了我的应用程序?

最佳答案

为此使用applicationDidBecomeActive

From Apple Developer Documentation:

WatchKit calls this method to let you know that your app transitioned from the inactive to the active state. Use this method to start any tasks that were paused or not yet started while the app was inactive.

关于ios - 如何知道用户何时启动了 Apple Watch 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48539032/

相关文章:

iphone - 如何在 Xcode 中的 _WebThreadLockFromAnyThread 上设置符号断点?

swift - 如何为 Apple Watch 添加加载 View ?

ios - 如何检测 WatchKit 语音转文本输入的语言?

ios - 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因 : -[__NSCFString scheme]: unrecognized selector sent to instance

Xamarin 中的 iOS 自定义 Collection View 单元格

iphone - 初始加载后使用 CGContextStrokePath 重绘路径

ios - 将对象映射到键/值列表

ios - 如何从 iPhone 上的 Watch 触发后台进程(触发器 : Watch)?

ios - WatchKit - 如何在首次启动时获取数据?

watchkit - 如何在 WatchKit 中创建静态表