2013-06-29 153 views
2

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

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

这是正确的吗?有没有办法让我的viewController在我第一次运行应用时得到UIApplicationDidBecomeActiveNotification的通知。

回答

0

,当你第一次运行的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被初始化youself后也不会被解雇。

+2

它在启动过程中实际上会发生火灾。也许OP在通知最初发布后订阅它。即使你从文档中引用的话也很清楚:“它在启动后获得了关注” – bhirt

相关问题