IOS判断版本

1. iOS版本确认
1

2

3

4

5

6

7

8

- (void)viewDidLoad {

    [super viewDidLoad];



    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 4.0) {

        bannerView = [[ADBannerView alloc] init];

        bannerView.delegate = self;

        [self.view addSubview:bannerView];

    }

2. 新类是否存在
1

2

3

4

5

6

Class clazz = NSClassFromString(@"ADBannerView");

if (clazz) {

    bannerView = [[ADBannerView alloc] init];

    bannerView.delegate = self;

    [self.view addSubview:bannerView];

}

3. 新接口是否存在
1

2

3

4

5

if (UIGraphicsBeginImageContextWithOptions != NULL) {

    bannerView = [[ADBannerView alloc] init];

    bannerView.delegate = self;

    [self.view addSubview:bannerView];

}

你可能感兴趣的:(ios)