多任务笔记

多任务笔记  

2010-08-17 23:44:39|  分类: cocoa |  标签:cocoa  iphone  objective-c   |字号 订阅

检测是否支持多任务
UIDevice* device = [UIDevice currentDevice];
BOOL backgroundSupported = NO;
if ([device respondsToSelector:@selector(isMultitaskingSupported)])
   backgroundSupported = device.multitaskingSupported;

后台运行的类别有3种
audio - The application plays audible content to the user while in the background.
location - The application keeps users informed of their location, even while running in the background.
voip - The application provides the ability for the user to make phone calls using an Internet connection.

还有另外的两种方法
Applications can ask the system for extra time to complete a given task.
Applications can schedule local notifications to be delivered at a predetermined time.

在plist文件中的key
UIBackgroundModes key in its Info.plist

几个状态的切换
application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillResignActive:
applicationDidEnterBackground:
applicationWillEnterForeground:
applicationWillTerminate:



在程序暂停之前.应用程序可以使用这个方法请求系统一些额外的时间完成 长期运行的任务
beginBackgroundTaskWithExpirationHandler
假如请求被同意,app进入后台,这个任务可以继续执行
UIApplication 的 backgroundTimeRemaining 属性表示还剩下多少运行时间
这个可以用在下载文件的时候,不会应为用户突然退出而中断

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值