<分区>
我正在尝试使用 iOS 8 中引入的新 UIAlertController
。一切都很好,除了 UIAlertAction
总是在其回调中关闭警报 Controller 。以下是我的代码:
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);
现在,当我单击“完成”按钮时,控件进入回调方法,然后警报被解除,即使我没有任何解除警报的语句。这是默认行为吗?如果是,我如何确保在某些情况下警报停留在屏幕上(取决于我的情况)?我在这里遗漏了什么吗?
我将非常感谢有关此的任何帮助。