• <legend id='mdK8Q'><style id='mdK8Q'><dir id='mdK8Q'><q id='mdK8Q'></q></dir></style></legend>
    <i id='mdK8Q'><tr id='mdK8Q'><dt id='mdK8Q'><q id='mdK8Q'><span id='mdK8Q'><b id='mdK8Q'><form id='mdK8Q'><ins id='mdK8Q'></ins><ul id='mdK8Q'></ul><sub id='mdK8Q'></sub></form><legend id='mdK8Q'></legend><bdo id='mdK8Q'><pre id='mdK8Q'><center id='mdK8Q'></center></pre></bdo></b><th id='mdK8Q'></th></span></q></dt></tr></i><div id='mdK8Q'><tfoot id='mdK8Q'></tfoot><dl id='mdK8Q'><fieldset id='mdK8Q'></fieldset></dl></div>
    1. <tfoot id='mdK8Q'></tfoot>

        <small id='mdK8Q'></small><noframes id='mdK8Q'>

          <bdo id='mdK8Q'></bdo><ul id='mdK8Q'></ul>

        处理 applicationDidBecomeActive -“视图控制器如何响应应用程序变为活动状态?"

        时间:2023-10-03
          • <bdo id='Fj0hQ'></bdo><ul id='Fj0hQ'></ul>
              <tbody id='Fj0hQ'></tbody>

              <tfoot id='Fj0hQ'></tfoot>
              <i id='Fj0hQ'><tr id='Fj0hQ'><dt id='Fj0hQ'><q id='Fj0hQ'><span id='Fj0hQ'><b id='Fj0hQ'><form id='Fj0hQ'><ins id='Fj0hQ'></ins><ul id='Fj0hQ'></ul><sub id='Fj0hQ'></sub></form><legend id='Fj0hQ'></legend><bdo id='Fj0hQ'><pre id='Fj0hQ'><center id='Fj0hQ'></center></pre></bdo></b><th id='Fj0hQ'></th></span></q></dt></tr></i><div id='Fj0hQ'><tfoot id='Fj0hQ'></tfoot><dl id='Fj0hQ'><fieldset id='Fj0hQ'></fieldset></dl></div>
              • <small id='Fj0hQ'></small><noframes id='Fj0hQ'>

                <legend id='Fj0hQ'><style id='Fj0hQ'><dir id='Fj0hQ'><q id='Fj0hQ'></q></dir></style></legend>
                • 本文介绍了处理 applicationDidBecomeActive -“视图控制器如何响应应用程序变为活动状态?"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的主 AppDelegate.m 类中有 UIApplicationDelegate 协议,并定义了 applicationDidBecomeActive 方法.

                  I have the UIApplicationDelegate protocol in my main AppDelegate.m class, with the applicationDidBecomeActive method defined.

                  我想在应用程序从后台返回时调用一个方法,但该方法在另一个视图控制器中.如何检查 applicationDidBecomeActive 方法中当前显示的视图控制器,然后调用该控制器中的方法?

                  I want to call a method when the application returns from the background, but the method is in another view controller. How can I check which view controller is currently showing in the applicationDidBecomeActive method and then make a call to a method within that controller?

                  推荐答案

                  应用程序中的任何类都可以成为应用程序中不同通知的观察者".当您创建(或加载)您的视图控制器时,您需要将其注册为 UIApplicationDidBecomeActiveNotification 的观察者,并指定当通知发送到您的应用程序时要调用的方法.

                  Any class in your application can become an "observer" for different notifications in the application. When you create (or load) your view controller, you'll want to register it as an observer for the UIApplicationDidBecomeActiveNotification and specify which method that you want to call when that notification gets sent to your application.

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

                  别忘了自己打扫卫生!当您的视图消失时,请记住将自己移除为观察者:

                  Don't forget to clean up after yourself! Remember to remove yourself as the observer when your view is going away:

                  [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                                  name:UIApplicationDidBecomeActiveNotification
                                                                object:nil];
                  

                  更多关于通知中心.

                  这篇关于处理 applicationDidBecomeActive -“视图控制器如何响应应用程序变为活动状态?"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为 iOS 应用程序中的 Facebook 身份验证设计,该应用程序还访问安全的 Web 服务 下一篇:获取 iOS 上所有联系人的列表

                  相关文章

                  <small id='TmKOX'></small><noframes id='TmKOX'>

                  1. <legend id='TmKOX'><style id='TmKOX'><dir id='TmKOX'><q id='TmKOX'></q></dir></style></legend>

                        <bdo id='TmKOX'></bdo><ul id='TmKOX'></ul>
                    1. <i id='TmKOX'><tr id='TmKOX'><dt id='TmKOX'><q id='TmKOX'><span id='TmKOX'><b id='TmKOX'><form id='TmKOX'><ins id='TmKOX'></ins><ul id='TmKOX'></ul><sub id='TmKOX'></sub></form><legend id='TmKOX'></legend><bdo id='TmKOX'><pre id='TmKOX'><center id='TmKOX'></center></pre></bdo></b><th id='TmKOX'></th></span></q></dt></tr></i><div id='TmKOX'><tfoot id='TmKOX'></tfoot><dl id='TmKOX'><fieldset id='TmKOX'></fieldset></dl></div>
                      <tfoot id='TmKOX'></tfoot>