// UIAlertView自带属性
if(alert.visible)
{
NSLog(@"显示了");
}else{
NSLog(@"未显示");
}
// UIAlertController没有visible属性,需要自己判断,添加一个全局变量 BOOL visible
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"ActionTitle" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self.visible =NO;
}];
UIAlertAction *calcelAction = [UIAlertAction actionWithTitle:@"calcelTitle" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
self.visible =NO;
}];
[alertControlleraddAction:alertAction];
[alertControlleraddAction:calcelAction];
[selfpresentViewController:alertController animated:YES completion:^{
self.visible =YES;
}];
网友评论