iOS中的多个UIAlertControllers [英] Multiple UIAlertControllers in iOS

查看:472
本文介绍了iOS中的多个UIAlertControllers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,有些情况可能会出现多个警报。但是在iOS8 UIAlertview转向UIAlertController时,我无法显示多个警报,因为您无法同时显示两个或更多控制器。

In my app there are scenarios where multiple alerts could come. But as in iOS8 UIAlertview turned to UIAlertController, i am not able to show multiple alerts as you can not present two or more controllers at the same time.

我如何实现这使用UIAlertController?

How can I achieve this using UIAlertController?

推荐答案

以下是显示多个alertControllers的方法:

Here is the method to show multiple alertControllers :

        UIAlertController *av = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];

        UIAlertAction *cancelAction = [UIAlertAction
                                       actionWithTitle:kAlertOk
                                       style:UIAlertActionStyleCancel
                                       handler:^(UIAlertAction *action)
                                       {

                                       }];
        [av addAction:cancelAction];

        UIWindow *alertWindow = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
        alertWindow.rootViewController = [[UIViewController alloc]init];
        alertWindow.windowLevel = UIWindowLevelAlert + 1;
        [alertWindow makeKeyAndVisible];
        [alertWindow.rootViewController presentViewController:av animated:YES completion:nil];

这篇关于iOS中的多个UIAlertControllers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆