我在init方法和viewDidLoad方法中调用了这行代码。但是,方法 applicationDidBecomeActiveNotification 永远不会在我第一次运行应用程序时触发。它只在我运行一次后运行。
[[NSNotificationCenter defaultCenter] addObserver:self
selectorselector(applicationDidBecomeActiveNotificationAction)
name:UIApplicationDidBecomeActiveNotification
object:nil];
这是对的吗?有没有办法让我的 viewController 在我第一次运行应用程序时收到 UIApplicationDidBecomeActiveNotification 通知。
Best Answer-推荐答案 strong>
第一次运行APP不会触发
UIApplicationDidBecomeActiveNotification
Posted when the application becomes active.
An application is active when it is receiving events. An active application can be said to have focus. It gains focus after being launched, loses focus when an overlay window pops up or when the device is locked, and gains focus when the device is unlocked.
你可以在APP初始化后自己触发。
关于ios - 首次运行应用程序时,UIApplicationDidBecomeActiveNotification 通知未触发,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/17375649/
|