• <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 -“视图控制器如何响应应用程序变为活动状态?"

        Handling applicationDidBecomeActive - quot;How can a view controller respond to the app becoming Active?quot;(处理 applicationDidBecomeActive -“视图控制器如何响应应用程序变为活动状态?)
          • <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 -“视图控制器如何响应应用程序变为活动状态?"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Resume game cocos2d(恢复游戏 cocos2d)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)

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

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

                        <tbody id='TmKOX'></tbody>

                          <bdo id='TmKOX'></bdo><ul id='TmKOX'></ul>
                          • <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>