我知道 here 所描述的方法与 applicationWillResignActive:
,但这是应用程序委托(delegate)中的一个方法。如果我在一个明显独立的 View Controller 中执行任务,我如何告诉该 View Controller 从应用程序委托(delegate)中暂停其事件?
最好是通过委托(delegate)来完成此操作吗?或者还有另一种更优选的方式吗?
最佳答案
对于需要它的 View Controller ,您可以使它们成为应用程序通知的观察者。有一系列通知,例如 UIApplicationWillResignActiveNotification
和 UIApplicationWillEnterForegroundNotification
,它们都发布到 defaultCenter
(NSNotificationCenter
)。
关于ios - 处理任务过程中中断(例如电话、电池警告)的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17474374/