目标C - 我想在单击按钮时不删除UIAlertController

Lud*_*uda 7 objective-c ios uialertcontroller uialertaction

我想呈现一个带有2个按钮的UIAlertController.

一个按钮应该关闭警报,第二个按钮应该执行操作但在屏幕上保持警报.是否有一些可以执行的配置,它不会关闭警报?

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"title"
                                                               message:@"message"
                                                        preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Do Something"
                                          style:UIAlertActionStyleDefault
                                        handler:^(UIAlertAction *action) {
    //Pressing this button, should not remove alert from screen
                                        }]];

[alert addAction:[UIAlertAction actionWithTitle:@"Close"
                                          style:UIAlertActionStyleDefault
                                        handler:^(UIAlertAction *action) {
    //Regular functionality- pressing removes alert from screen 
                                        }]];


[alert show];
Run Code Online (Sandbox Code Playgroud)

建议将此(防止UIAlertController解除)作为可能的答案,但问题涉及文本字段.我需要其中一个操作按钮,以便在按下时不关闭警报.

Iva*_*nin 6

你不能这样做.

只有一种解决方案是创建一个看起来像本机的自定义视图控制器UIAlertController.