iOS程序退出

来源:互联网 发布:cs8录屏软件 编辑:程序博客网 时间:2024/05/16 06:12

程序不在后台运行,直接完全退出的方法:

plist文件中添加  Application does not run in background 设为YES


原理:在程序切入到后台后,每十分钟就去执行一个动作来唤醒程序,由此来保证它一直在后台运行。

1、在Info.plist中添加UIBackgroundModes 键值

让系统知道你的应用程序应该在适当的时候被唤醒

2、在 - (void)applicationDidEnterBackground:(UIApplication *)application  切入后台执行的方法中执行下面代码

[[UIApplication sharedApplication]setKeepAliveTimeout:600                                                  handler:^{                                                      //执行的代码                                                    }];


0 0
原创粉丝点击