ios - 处理任务过程中中断(例如电话、电池警告)的最佳方法

标签 ios objective-c delegates uiapplicationdelegate appdelegate

我知道 here 所描述的方法与 applicationWillResignActive:,但这是应用程序委托(delegate)中的一个方法。如果我在一个明显独立的 View Controller 中执行任务,我如何告诉该 View Controller 从应用程序委托(delegate)中暂停其事件?

最好是通过委托(delegate)来完成此操作吗?或者还有另一种更优选的方式吗?

最佳答案

对于需要它的 View Controller ,您可以使它们成为应用程序通知的观察者。有一系列通知,例如 UIApplicationWillResignActiveNotificationUIApplicationWillEnterForegroundNotification,它们都发布到 defaultCenter (NSNotificationCenter)。

关于ios - 处理任务过程中中断(例如电话、电池警告)的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17474374/

相关文章:

ios - AudioKit:使用 AKOperationEffect 时如何切换滤波器类型?

ios - 我只能通过prepareforSegue将新单元添加到 Collection View Controller

ios - IBAction 未注册按钮单击

ios - UIColor 和 CIColor 它们如何比较,它们有两个的目的是什么?

ios - 从 subview 中更改在父 View 上设置的约束

ios - 在 xCode 中动态调试变量?

iphone - 使用不推荐使用的UDID的openUDID

ios - 如何在 iOS 中按预定时间发送短信/电子邮件

ios - UIView 和 subview 委托(delegate)

delphi - 如何获取方法指针指向的方法的名称?