【问题标题】:How to close WatchKit app如何关闭 WatchKit 应用
【发布时间】:2015-02-12 07:39:34
【问题描述】:

有没有办法关闭WatchKit 应用程序?

在 iOS 模拟器中有一个主页按钮 (cmd + shift + h) 将触发关闭应用事件。我想知道WatchKit 模拟器中是否有类似的东西?

问题 - 我有一个WKInterfaceController,但我从未收到“didDeactivate”方法调用。

【问题讨论】:

  • 我认为这可能是因为 Apple 不想在 Apple Watch 发布之前展示它的外观。
  • zisoft - 没有意义 - Apple Watch 模拟器已经在这里,似乎他们没有实现/发布“关闭手表应用程序”功能。
  • @lvp 它仍处于测试阶段。要显示主屏幕,他们必须具有处于工作状态的默认 iWatch 应用程序。哪个看起来他们没有它,或者他们不想按照 zisoft 的建议显示它
  • 是的,我同意,但另一方面,它们只能在 WatchApp 关闭时显示黑屏 - 就像在 iOS 模拟器中锁定屏幕时一样。
  • 同意@lvp。只要黑屏就够了。当您启动外接显示器(38 或 42)毫米手表时,它首先显示黑屏。他们也可以在您关闭应用程序时显示它

标签: ios ios-simulator watchkit


【解决方案1】:

不,此功能目前在 iOS 模拟器中不可用。当前的实现不是手表的完整模拟器,它只是 WatchKit 的模拟器,作为连接到模拟 iPhone 的外部显示器(而不是单独的设备)实现。

您最接近的方法是通过转到硬件 -> 外接显示器菜单并选择“禁用”来关闭外接显示器

【讨论】:

  • didDeactivate 无论如何都没有被调用。
【解决方案2】:

引用https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/DesigningaWatchKitApp.html

During testing, you can lock and unlock the simulator to verify that your
activation and deactivation code is working as expected. 
When you use the Hardware > Lock command to lock the simulator, 
WatchKit calls the didDeactivate method of the current interface controller. 
When you subsequently unlock the simulator, 
WatchKit calls the willActivate method of the interface controller.

【讨论】:

    猜你喜欢
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-09
    • 1970-01-01
    • 2015-06-13
    • 2015-09-09
    相关资源
    最近更新 更多