显示iOS7,iOS8的警报

由于UIAlertController用于显示IOS8.my应用程序中的警报应与ios6,ios7兼容。我认为ios6,7仍在使用UIAlertView来显示警报。 我想在通过使用UIAlertView的ios7和使用UIAlertController ios8的不同方式检查ios6,7,8之后显示警报。我需要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]; }