由于UIAlertController
用于iOS8中显示警报,我的应用程序也应该与ios6,ios7兼容。我认为ios6,7仍在使用UIAlertView
中显示警报。我想以不同的方式检查ios6、7、8后显示警报,例如使用ios7UIAlertView
和使用ios8 UIAlertController
。我需要objectiv-c代码。
请帮忙!!
提前致谢!!
检查课程是否可用
if ([UIAlertController class]){
// ios 8 or higher
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Alert title" message:@"Alert message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:ok];
[self presentViewController:alertController animated:YES completion:nil];
} else {
// ios 7 or lower
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"Alert title" message:@"Alert message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句