OGeek|极客世界-中国程序员成长平台

标题: ios - 首次运行应用程序时,UIApplicationDidBecomeActiveNotification 通知未触发 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 12:04
标题: ios - 首次运行应用程序时,UIApplicationDidBecomeActiveNotification 通知未触发

我在init方法和viewDidLoad方法中调用了这行代码。但是,方法 applicationDidBecomeActiveNotification 永远不会在我第一次运行应用程序时触发。它只在我运行一次后运行。

 [[NSNotificationCenter defaultCenter] addObserver:self
          selectorselector(applicationDidBecomeActiveNotificationAction)
                           name:UIApplicationDidBecomeActiveNotification
                                               object:nil];

这是对的吗?有没有办法让我的 viewController 在我第一次运行应用程序时收到 UIApplicationDidBecomeActiveNotification 通知。



Best Answer-推荐答案


第一次运行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/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4