简体   繁体   English

如何在iOS中获取共享扩展的状态?

[英]How to get the state of share extension in iOS?

I'm developing a share extension for my app. 我正在为我的应用程序开发一个共享扩展。
I know that the following methods will be fired, if user minimize and reopen the app. 我知道,如果用户最小化并重新打开应用程序,则会触发以下方法。

- (void)applicationDidEnterBackground:(UIApplication *)application
- (void)applicationWillEnterForeground:(UIApplication *)application

I need the same thing when user minimize the share extension. 用户最小化共享扩展名时,我需要同样的东西。 The above method are not getting fired in shared extension. 共享扩展中不会触发上述方法。
I'm using UIViewController as super class of my share extension. 我将UIViewController用作共享扩展的超类。 Tried the following methods. 尝试了以下方法。

- (void)viewDidAppear:(BOOL)animated
- (void)viewDidDisappear:(BOOL)animated

-viewDidDisappear is not getting called when user minmize the app. -viewDidDisappear当用户minmize应用程序是没有得到调用。

Is it possible to know if user minimize the shared extension? 是否可以知道用户是否最小化共享扩展名?

I need your valuable suggestions. 我需要您的宝贵建议。
Thanks in advance 提前致谢

You have to call -[NSExtensionContext completeRequestReturningItems:completionHandler:] to return control to the host application. 您必须调用-[NSExtensionContext completeRequestReturningItems:completionHandler:]将控制权返回给主机应用程序。 Use that as an opportunity to know your share extension is being dismissed. 借此机会知道您的股票扩展名已被撤消。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM