如何从viewController访问applicationDidEnterBackground [英] How to access applicationDidEnterBackground from viewController

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

问题描述

如何从viewController调用AppDelegate中的applicationDidEnterBackground?

我想在应用程序的后台运行一个功能,而无需按主页按钮.

I want to run a function in the background of the app without pressing home button.

推荐答案

您不应从任何地方调用该函数.该应用程序可让您知道应用程序何时进入后台.

You are not supposed to call that function from anywhere. It is there to let you know when the app enters the background.

您是否只想知道应用何时进入后台?如果是这样,那么您可以创建一个通知来帮助您:

Do you simply want to know when the app enters the background? If so, then you can create a notification to help you with that:

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

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

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