NS_CLASS_DEPRECATED_IOS(2_0, 9_0, "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead") __TVOS_PROHIBITED

大概意思是说9以后用UIAlertController代替UIAlertView,9以前还是UIAlertView

double version = [[UIDevice currentDevice].systemVersion doubleValue];//判定系统版本。

    if(version>=9.0f){

        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:nil preferredStyle:UIAlertControllerStyleAlert];

        [alertController addAction: [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            NSLog(@"确定");

        }]];

        [alertController addAction: [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            NSLog(@"取消");

        }]];

        [self presentViewController:alertController animated:YES completion:nil];


    }else{

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定",@"取消", nil];

   

        [alertView show];

    }

#pragma mark UIAlertView 点击事件

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 9_0){

    NSLog(@"%@",@(buttonIndex));

}