//判断Xcode的版本
float version = [UIDevice currentDevice].systemVersion.floatValues;
if (version < 8.0) {
//iOS8.0以前UIAlertView
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"密码不正确,请重新输入。" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",@"很确定",@"非常确定", nil];
//弹出alertView
[alertView show];
}else{
//iOS8.0以后UIAlertController
//UIAlertControllerStyleActionSheet上弹提示框
//UIAlertControllerStyleAlert屏幕中间弹出提示框
//使用模态展示
UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"提示" message:@"密码错误,请重新输入。" preferredStyle:UIAlertControllerStyleActionSheet];
//添加点击按钮
[alertC addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击确定");
}]];
[self presentViewController:alertC animated:YES completion:^{
}];
}
#pragma mark - UIAlertViewDelegate的代理方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%ld",buttonIndex);
}