applicationDidEnterBackground [英] applicationDidEnterBackground

查看:101
本文介绍了applicationDidEnterBackground的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

退出应用程序时会自动调用此函数。但在我的应用程序中,此函数无法自动调用

this function is called automatically when quit application..but in my application this function cannot called automatically

推荐答案

此方法是在您的 ApplicationDelegate 实例上调用 ,所以这是您放置代码的地方吗?

This method is only called on your ApplicationDelegate instance so is this where you put your code?

如果您需要通知您的应用程序何时在ApplicationDelegate之外进入后台,您可以注册 NSNotificationCenter

If you need to be notified of when your application enters background outside of the ApplicationDelegate you can register with NSNotificationCenter.

[[NSNotificationCenter defaultCenter] addObserver: whatever
    selector: @selector(enteredBackground:) 
    name: UIApplicationDidEnterBackgroundNotification
    object: nil];

这适用于任何类,但你显然需要创建方法 enterBackground 或者你称之为的任何东西:)

This will work in any class, but you obviously need to create the method enteredBackground or whatever you call it :)

这篇关于applicationDidEnterBackground的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆