UIAlertAction在其回调中解散UIAlertController

Vik*_*ngh 4 swift ios8 uialertcontroller

我正在尝试使用UIAlertControlleriOS 8中引入的新功能.除了UIAlertAction总是最终在其回调中解除警报控制器这一事实外,一切都很有效.以下是我的代码:

let alert = UIAlertController(title: "New Group", message: "Enter Group name", preferredStyle: UIAlertControllerStyle.Alert);
alert.addTextFieldWithConfigurationHandler({ [weak self] (nameField: UITextField!) in
    nameField.becomeFirstResponder();
    nameField.delegate = self;
    return;
})
alert.addAction(UIAlertAction(title: "Done", style: .Default, handler: { action in
    println("Done Entering");
}));
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil));
self.presentViewController(alert, animated: true, completion: nil);
Run Code Online (Sandbox Code Playgroud)

现在,当我单击"完成"按钮时,控件进入回调方法,然后警报被解除,即使我没有任何声明来解除警报.这种行为是默认的吗?如果是,我怎样才能确保在某些情况下警报停留在屏幕上(取决于我的条件)?我在这里错过了什么吗?

我真的很感激有关这方面的任何帮助.

Sco*_*ets 10

是的,警报按钮总是关闭警报,否则无法配置它们.如果您想要这种行为,则必须编写自己的警报.我写过SDCAlertView,看起来非常像普通警报,但有一些附加功能,包括防止在点击按钮时解除警报.

但是,它还没有使用UIAlertControllerAPI,它在iOS 8上看起来有点不同(大多数用户不会注意到)而不是UIAlertController警报.

编辑:它现在支持UIAlertController类似API.