应用程序进入后台——应用程序运行时点击主页按钮

发布于 2024-11-09 11:38:58 字数 176 浏览 0 评论 0原文

当我们点击 iPhone 上的主页按钮时,即当应用程序进入后台时,调用的方法的顺序是什么?

基本上,我想在我的应用程序进入后台之前进行服务器调用。我正在 applicationWillResignActive: 中编写服务器调用代码,但有时会执行,有时不会。

我需要一个解决方案。

What is the sequence of methods that gets called when we tap on the home button on iPhone, i.e. when an application is going in background.

Basically, I want to make a server call before my app goes in background. I am writing my server call code in applicationWillResignActive:, but sometimes it executes and sometimes it doesn't.

I need a solution for this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丶情人眼里出诗心の 2024-11-16 11:38:58

从应用程序委托文件本身:

- (void)applicationDidEnterBackground:(UIApplication *)application {
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, called instead of applicationWillTerminate: when the user quits.

     Superclass implementation saves changes in the application's managed object context before the application terminates.
     */
    [super applicationDidEnterBackground:application];
}

尝试使用此方法......

From the app delegate file itself:

- (void)applicationDidEnterBackground:(UIApplication *)application {
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, called instead of applicationWillTerminate: when the user quits.

     Superclass implementation saves changes in the application's managed object context before the application terminates.
     */
    [super applicationDidEnterBackground:application];
}

Try using this method.....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文