iphone - 当应用程序从后台重新启动时,我的 AppDelegate.m 中的什么方法被执行?

标签 iphone objective-c ios

我有一个具有本地数据库的应用程序,我希望在从后台调用该应用程序时调用一个函数(即当我从“任务管理器”中调用它时),以便我可以从网络服务更新我的数据库.调用的方法是什么?我可以让它在我的应用程序的委托(delegate)中执行吗?

最佳答案

检查 UIApplicationDelegate 中的 applicationWillEnterForeground:applicationDidBecomeActive 方法。

applicationWillEnterForeground

In iOS 4.0 and later, this method is called as part of the transition from the background to the active state. You can use this method to undo many of the changes you made to your application upon entering the background. The call to this method is invariably followed by a call to the applicationDidBecomeActive: method, which then moves the application from the inactive to the active state.

关于iphone - 当应用程序从后台重新启动时,我的 AppDelegate.m 中的什么方法被执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7496135/

相关文章:

ios - 使用 Codable 解析 JSON 响应会 swift 出错

iphone - 按两次主页按钮时 iPhone 中的应用程序关闭通知

objective-c - 如何在 Objective-C/Iphone SDK 中定义返回 NSString 的函数

iphone - 喜欢 iOS 5 中的图表吗? (也许皮肤核心情节?)

iphone - 不同实体的多个 NSFetchedResultControllers?

objective-c - iOS 和 OS X 之间的多点连接

iphone - 在 SpriteKit 中改变方向而不是速度(swift)

objective-c - 没有夏令时的日期计算

ios - carthage build 不适用于 Xcode 12.0,它适用于 Xcode 11.3。任务失败,退出代码 1 :

ios - Mplayer 支持 SMB