編譯時(shí)檢查sdk版本,運(yùn)行時(shí)檢查系統(tǒng)版本园细,這是最基本的適配手段
//編譯時(shí)判斷:sdk版本iOS10
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
//運(yùn)行時(shí)判斷:當(dāng)前系統(tǒng)版本
if ([UIDevice currentDevice].systemVersion.floatValue >= 10.0) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.baidu.com"] options:nil completionHandler:^(BOOL success) {
}];
}else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.baidu.com"]];
}
#else
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.baidu.com"]];
#endif