我想知道用户何时启动我的 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/