2
我正尝试使用在iOS 8中引入的新的UIAlertController
。除了事实上UIAlertAction
总是最终关闭其回调中的警报控制器这一事实,一切都很好。以下是我的代码:UIAlertAction在其回调中关闭了UIAlertController
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);
现在,当我点击“完成”按钮,该控件中输入回调方法,然后警报被驳回,即使我没有任何声明,解除警报。这是默认情况下的行为吗?如果是的话,我怎样才能确保在某些情况下警报停留在屏幕上(取决于我的条件)?我在这里错过了什么吗?
我真的很感谢这方面的帮助。