检测应用程序打开? [英] Detect app opening?

查看:53
本文介绍了检测应用程序打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有3个视图控制器的Tab栏应用,我使用"viewWillAppear"来检测打开了哪个视图.

I have a Tab bar app with 3 view controllers and I use "viewWillAppear" to detect which view is opend.

当我关闭该应用程序时,它仍然可以在后台"运行,而当我再次打开该应用程序时,"viewWillAppear"未检测到此打开.

When I close the app, it still works "in the background" and when I open the app again "viewWillAppear" is not detecting this opening.

还有其他选择可以检测到此打开吗?谢谢

Is there any other option to detect this opening? Thanks

推荐答案

首先,您应该在 UIApplicationDelegate

  • 当关闭当前打开的应用程序时,它将调用此方法:

  • When you close application that currently open, It will call this method:

-(void)applicationDidEnterBackground:(UIApplication *)application

在关闭应用程序但仍在扩展坞中之后,请再次打开它们.在进入应用程序之前的过渡状态下,它将调用此方法:

After the application has been closed but still in dock, you open them again. In the transition state before entering the application, It will call this method:

-(void)applicationWillEnterForeground:(UIApplication *)application

在关闭它们之前,应用程序完全呈现为先前状态.最后调用thid方法:

When the application completely presented on previous state before you closed them. It finally call thid method:

-(void)applicationDidBecomeActive:(UIApplication *)application

如果您想在 viewWillAppear 中做某事,则应在 applicationDidBecomeActive 中实现,以将消息发送到当前视图或其他,以便在以后执行您想做的事情应用程序已激活.

If you would like to do something in viewWillAppear you should implement in applicationDidBecomeActive to send some message to your current view or other to do what do you want to do after application became actived.

这篇关于检测应用程序打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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