gpt4 book ai didi

iOS 8 共享扩展 : is there callback available to know if user quit the host app while the share extension is being presented?

转载 作者:行者123 更新时间:2023-11-29 12:26:51 24 4
gpt4 key购买 nike

在显示共享扩展 View Controller (可见)时,是否有回调方法可以在扩展的 View Controller 中实现,以了解用户何时按下主页按钮,这将导致主机应用退出事件状态?

我尝试了以下方法:

  • viewWillDisappear:
  • viewDidDisappear:
  • UIApplicationWillResignActiveNotification
  • UIApplicationDidEnterBackgroundNotification

以上均无效。

我需要回调,以便当用户关闭应用程序时,我想暂停当前在共享扩展进程中运行的所有网络操作。

最佳答案

您可以注册以下通知(在 NSExtensionContext 中定义):

  • NSExtensionHostWillEnterForegroundNotification
  • NSExtensionHostDidEnterBackgroundNotification
  • NSExtensionHostWillResignActiveNotification
  • NSExtensionHostDidBecomeActiveNotification

-viewWillDisappear:/-viewDidDisappear: 仅适用于用于呈现共享扩展的 View Controller 。

关于iOS 8 共享扩展 : is there callback available to know if user quit the host app while the share extension is being presented?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28807881/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com