iOS中检测是否支持多任务
2012-02-22 15:36
330 查看
- (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位
- iOS 支持多任务、断点下载(图片、音频、视频) (Demo 一)
- 检测浏览器是否支持HTML5功能
- Mac下检测ios应用内是否有私有API
- iOS - 检测耳机孔是否存在耳机:
- javascript/js 检测浏览器类型和版本,检查浏览器是否支持flash,检查flash版本一站搞定~
- 检测网站是否支持gzip的本地代码
- ios检测应用程序是否存在并启动
- 检测CSS属性 是否支持
- 检测FP是否支持stage3D
- 检测您的浏览器是否支持 HTML5 视频方法
- 检测App、静态库、framework是否支持bitcode
- 如何判断一个类是否支持某属性和方法以及如何判断IOS的版本
- iOS NSURLSession后台下载多个任务,支持断点续传
- ios应用中检测是否安装其他应用
- iOS 应用中检测网络是否存在的方法