applicationDidEnterBackground

sid*_*dhu -1 iphone

退出应用程序时会自动调用此函数.但在我的应用程序中,此函数无法自动调用

wil*_*ood 11

这个方法在你的ApplicationDelegate实例上调用,所以这是你放置代码的地方吗?

如果您需要通知您的应用程序何时进入ApplicationDelegate之外的后台,您可以注册NSNotificationCenter.

[[NSNotificationCenter defaultCenter] addObserver: whatever
    selector: @selector(enteredBackground:) 
    name: UIApplicationDidEnterBackgroundNotification
    object: nil];
Run Code Online (Sandbox Code Playgroud)

这适用于任何类,但你显然需要创建方法enteredBackground或任何你称之为:)