iOS中检测是否支持多任务
2011-12-27 17:12
176 查看
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
RootViewController *rootController=[[RootViewControlleralloc]
init];
rootController.title =
@"Root";
navController = [[UINavigationControlleralloc]
initWithRootViewController:rootController];
[rootController release];
[self.windowaddSubview:navController.view];
[self.windowmakeKeyAndVisible];
//检测是否支持多任务.
UIDevice* device = [UIDevicecurrentDevice];
BOOL backgroundSupported =NO;
if ([devicerespondsToSelector:@selector(isMultitaskingSupported)]) {
backgroundSupported = device.multitaskingSupported;
NSLog(@"background supported:%d", backgroundSupported);
}
return YES;
}
如果支持,则会打印1,否则打印0.
iOS4以前的版本操作系统不支持多任务,因而应用一旦离开前台foreground,即被终止。
iOS4及以后的版本支持多任务,但也有某些运行iOS4版本系统但是不支持多任务的设备的情况。支持多任务的系统,当应用离开前台时,会短暂切入inactive状态,然后切入后台background状态。在后台时若不处理事件,则稍后不久便被挂起,即进入suspended状态。
之所以不退出是为了方便下次再次启动应用时能很快速的启动。
之所以要挂起是为了减少功耗。
// Override point for customization after application launch.
RootViewController *rootController=[[RootViewControlleralloc]
init];
rootController.title =
@"Root";
navController = [[UINavigationControlleralloc]
initWithRootViewController:rootController];
[rootController release];
[self.windowaddSubview:navController.view];
[self.windowmakeKeyAndVisible];
//检测是否支持多任务.
UIDevice* device = [UIDevicecurrentDevice];
BOOL backgroundSupported =NO;
if ([devicerespondsToSelector:@selector(isMultitaskingSupported)]) {
backgroundSupported = device.multitaskingSupported;
NSLog(@"background supported:%d", backgroundSupported);
}
return YES;
}
如果支持,则会打印1,否则打印0.
iOS4以前的版本操作系统不支持多任务,因而应用一旦离开前台foreground,即被终止。
iOS4及以后的版本支持多任务,但也有某些运行iOS4版本系统但是不支持多任务的设备的情况。支持多任务的系统,当应用离开前台时,会短暂切入inactive状态,然后切入后台background状态。在后台时若不处理事件,则稍后不久便被挂起,即进入suspended状态。
之所以不退出是为了方便下次再次启动应用时能很快速的启动。
之所以要挂起是为了减少功耗。
相关文章推荐
- iOS中检测是否支持多任务
- iOS中检测是否支持多任务
- 检测设备是否支持多任务
- iOS----------检测域名是否支持ipv6
- iOS检测静态库是否支持64位
- javascript检测浏览器是否支持某些事件
- ios-是否需要合成支持模拟器和真机架构的静态库
- iOS检测QQ是否安装
- iOS开发>学无止境 - 检测路径下文件夹是否存在
- 检测浏览器是否支持querySelectorA…
- 检测客户端浏览器是否支持cookie
- 检测浏览器是否支持html5 <video>标签 javascript
- 移动Web开发,4行代码检测浏览器是否支持position:fixed
- 如何判断一个类是否支持某属性和方法以及如何判断IOS的版本
- iOS 新特性分列式 之 iOS 7.x - 主要内容:扁平 UI、64位支持、多任务加强、Objective-C 模块支持
- iOS检测网络是否断开
- 检测apache是否支持htaccess文件
- iOS检测是否开启定位、是否允许消息通知
- 检测Apache是否支持mod_rewrite 如何开启.htaccess
- iOS应用中检测第三方app是否安装及跳转解决方案