【问题标题】:Which delegate function is called within a class on tapping the home-button在点击主页按钮时在类中调用哪个委托函数
【发布时间】:2012-12-06 05:37:16
【问题描述】:

当用户离开班级时,我有一个必须隐藏的弹出窗口。 在点击主页按钮时,不会发生。

- (void)applicationDidBecomeActive:(UIApplication *)application

- (void)applicationDidEnterBackground:(UIApplication *)application

除了上述函数之外,还有其他可以在同一个类中调用的委托函数(不是 app-delegate 类)。

【问题讨论】:

    标签: ios delegates onresume home-button


    【解决方案1】:

    只有UIApplicationDelegate 定义了这些方法。如果您希望任何其他类处理这些事件,则需要让该类注册相应的通知。

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backgrounding) name:UIApplicationDidEnterBackgroundNotification object:nil];
    

    别忘了移除观察者。

    那你需要方法:

    - (void)backgrounding {
        // App entered background
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-11
      • 1970-01-01
      • 2017-01-21
      • 1970-01-01
      • 2017-10-05
      • 1970-01-01
      • 1970-01-01
      • 2014-08-23
      相关资源
      最近更新 更多