菜鸟教程小白 发表于 2022-12-12 12:04:45

ios - 首次运行应用程序时,UIApplicationDidBecomeActiveNotification 通知未触发


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

<pre><code> [ addObserver:self
          selector:@selector(applicationDidBecomeActiveNotificationAction)
                           name:UIApplicationDidBecomeActiveNotification
                                             object:nil];
</code></pre>

<p>这是对的吗?有没有办法让我的 viewController 在我第一次运行应用程序时收到 UIApplicationDidBecomeActiveNotification 通知。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>第一次运行APP不会触发</p>

<pre><code>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.
</code></pre>

<p>你可以在APP初始化后自己触发。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 首次运行应用程序时,UIApplicationDidBecomeActiveNotification 通知未触发,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/17375649/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/17375649/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 首次运行应用程序时,UIApplicationDidBecomeActiveNotification 通知未触发