最多能运行多长时间,没挑战过极限,具体能保持多长时间需要自己测试下。
注意:用真机测试
直接上代码
在appdelegate的.m中的进入后台时加入一些代码操作即可
- - (void)applicationDidEnterBackground:(UIApplication *)application
- {
-
-
- __block UIBackgroundTaskIdentifier task = [application beginBackgroundTaskWithExpirationHandler:^{
-
-
-
- [application endBackgroundTask:task];
- }];
-
-
-
-
-
-
-
-
-
-
-
-
- }
iOS开发简单的实现后台任务(诸如后台播放音乐,定时器,后台定位等)
原文:http://www.cnblogs.com/Yishu/p/7515569.html