iOS8 UIAlertView键盘闪一下的问题

时间:2022-01-30 19:25:15
 if (SYSTEM_VERSION >= 8.0) {
UIAlertController *alertCtrl = [UIAlertController alertControllerWithTitle:@"赎回成功" message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self.navigationController popViewControllerAnimated:YES];
}];
[alertCtrl addAction:okAction];
[self presentViewController:alertCtrl animated:YES completion:nil]; }else{
//这个else一定要写,否则会导致在ios8一下的真机crash
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"赎回成功" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
alert.tag = ;
[alert show];
} #pragma mark-UIAlertViewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag == ) {
[self.navigationController popViewControllerAnimated:YES];
}
}

iOS 8 以后不用alertView了。使用UIAlertController代替。使用方法相同。