iOS程序压入后台,延续运行十分钟的方法
来源:互联网 发布:编程专用笔记本 编辑:程序博客网 时间:2024/06/01 07:13
模拟器测试不准确,需要真机测试
UIBackgroundTaskIdentifier _backgroundTask;- (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. [self beginBackgroundTask]; int count = 0; while (YES) { NSLog(@"%d",count); count ++; [NSThread sleepForTimeInterval:5]; } [self endBackgroundTask];}- (void)beginBackgroundTask{ _backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ [self endBackgroundTask]; }];}- (void)endBackgroundTask{ [[UIApplication sharedApplication] endBackgroundTask:_backgroundTask]; _backgroundTask = UIBackgroundTaskInvalid;}
0 0
- iOS程序压入后台,延续运行十分钟的方法
- iOS让程序退出后台时继续运行10分钟
- iOS 4程序直接退出不在后台运行的方法
- iOS 4程序直接退出不在后台运行的方法
- ios 让程序在后台长久运行的方法
- XZ_iOS之iOS禁止程序在后台运行和申请后台3分钟的时长
- ios后台运行程序
- ios后台运行程序
- iOS后台运行程序
- ios 程序后台运行
- iOS 后台运行程序
- iOS后台运行程序
- 关于ios程序的后台运行
- ios后台运行程序 的一些总结
- 关于ios程序的后台运行
- 关于ios程序的后台运行
- unix下后台运行程序的方法
- Linux 程序后台运行的简单方法
- TCP协议
- EA代码工程---轻松几步教你更改"EA生成的源代码表头注释格式"
- 关于安卓插件式开发
- 远程绑定Service使用Messenger通讯
- ECONNRESET (Connection reset by peer) on a server with authentication解决方案
- iOS程序压入后台,延续运行十分钟的方法
- mac 下的头脑风暴软件 xLine icon 添加和取消
- 直接提取四个顶点坐标
- iOS之RSA解密
- 无向图-邻接表表示
- 开发辅助工具-ddms
- 当大数据遇到安全分析:思科OpenSOC即将开源
- 关于MVC
- About Modifying the SERVICE_NAMES Parameter for Oracle RAC