美文网首页
(IOS)判断一个UIAlertView/UIAlertCont

(IOS)判断一个UIAlertView/UIAlertCont

作者: rightmost | 来源:发表于2018-08-10 17:32 被阅读0次

 // 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;

    }];

相关文章

网友评论

      本文标题:(IOS)判断一个UIAlertView/UIAlertCont

      本文链接:https://www.haomeiwen.com/subject/qgjlbftx.html