gpt4 book ai didi

ios - 什么时候调用 applicationDidBecomeActive?

转载 作者:可可西里 更新时间:2023-11-01 03:22:36 27 4
gpt4 key购买 nike

applicationDidBecomeActive 方法何时被调用?这个方法的目的是什么?

最佳答案

了解 iOS 的状态和转换

未运行 - 应用未运行。

Inactive - 应用程序在前台运行,但未接收事件。 iOS 应用程序可以置于非事件状态,例如,当收到电话或短信时。

事件 - 应用正在前台运行,并接收事件。

后台 - 应用在后台运行并执行代码。

已暂停 - 应用程序在后台,但没有代码正在执行。

七个最重要的应用委托(delegate)方法

The operating system calls specific methods within the application delegate to facilitate transitioning to and from various states. The seven most important application delegate methods a developer should handle are:

应用程序:willFinishLaunchingWithOptions

Method called when the launch process is initiated. This is the first opportunity to execute any code within the app.

应用程序:didFinishLaunchingWithOptions

Method called when the launch process is nearly complete. Since this method is called is before any of the app's windows are displayed, it is the last opportunity to prepare the interface and make any final adjustments.

applicationDidBecomeActive

Once the application has become active, the application delegate will receive a callback notification message via the method applicationDidBecomeActive.

This method is also called each time the app returns to an active state from a previous switch to inactive from a resulting phone call or SMS.

applicationWillResignActive

There are several conditions that will spawn the applicationWillResignActive method. Each time a temporary event, such as a phone call, happens this method gets called. It is also important to note that "quitting" an iOS app does not terminate the processes, but rather moves the app to the background.

applicationDidEnterBackground

This method is called when an iOS app is running, but no longer in the foreground. In other words, the user interface is not currently being displayed. According to Apple's UIApplicationDelegate Protocol Reference, the app has approximately five seconds to perform tasks and return. If the method does not return within five seconds, the application is terminated.

applicationWillEnterForeground

This method is called as an app is preparing to move from the background to the foreground. The app, however, is not moved into an active state without the applicationDidBecomeActive method being called. This method gives a developer the opportunity to re-establish the settings of the previous running state before the app becomes active.

applicationWillTerminate

This method notifies your application delegate when a termination event has been triggered. Hitting the home button no longer quits the application. Force quitting the iOS app, or shutting down the device triggers the applicationWillTerminate method. This is the opportunity to save the application configuration, settings, and user preferences.

需要更多信息请引用 link1或苹果link2

关于ios - 什么时候调用 applicationDidBecomeActive?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30748555/

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