判断ios版本

在AppDelegate方法里,添加类方法

+ (NSInteger)OSVersion;

实现为

+ (NSInteger)OSVersion
{
    static NSUInteger _deviceSystemMajorVersion = -1;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];
    });
    return _deviceSystemMajorVersion;
}

使用时先导入

#import "AppDelegate.h"

直接使用[AppDelegate OSVersion]获取信息,如7,6等

posted on 2014-08-20 11:10  李园春秋  阅读(174)  评论(0编辑  收藏  举报

导航