【发布时间】:2015-06-10 13:30:23
【问题描述】:
我已经为我的应用设置了一个警报控制器,它的工作方式是如果部分分数高于 10,你会收到一个 UI 警报。
现在我的问题是,如果我有超过 10 个的 2 或 3 个部分,我只会显示第一个 UIalert,我希望一个接一个地看到所有这些(如果发生这种情况
这是我的代码:
func SectionAlert () {
var message1 = NSLocalizedString("Section 1 score is now ", comment: "");
message1 += "\(section1score)";
message1 += NSLocalizedString(" please review before continuing", comment: "1");
var message2 = NSLocalizedString("Section 2 score is now ", comment: "");
message2 += "\(section2score)";
message2 += NSLocalizedString(" please review before continuing", comment: "2");
var message3 = NSLocalizedString("Section 3 score is now ", comment: "");
message3 += "\(section3score)";
message3 += NSLocalizedString(" please review before continuing", comment: "3");
if (section1score >= 10){
let alertController: UIAlertController = UIAlertController(title: NSLocalizedString("Section 1 score is over 10", comment: ""),
message: " \(message1)",
preferredStyle: .Alert)
let OKAction = UIAlertAction(title: "OK", style: .Default) {
action -> Void in }
alertController.addAction(OKAction)
self.presentViewController(alertController, animated: true, completion: nil)
} else if (section2score >= 10){
let alertController: UIAlertController = UIAlertController(title: NSLocalizedString("Section 2 Score is over 10", comment: ""),
message: "\(message2)",
preferredStyle: .Alert)
let OKAction = UIAlertAction(title: "OK", style: .Default) {
action -> Void in }
alertController.addAction(OKAction)
self.presentViewController(alertController, animated: true, completion: nil)
} else if (section3score >= 10){
let alertController: UIAlertController = UIAlertController(title: NSLocalizedString("Section 3 Score is over 10", comment: ""),
message: "\(message3)",
preferredStyle: .Alert)
let OKAction = UIAlertAction(title: "OK", style: .Default) {
action -> Void in }
alertController.addAction(OKAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
}
有什么想法吗??
谢谢!
【问题讨论】:
标签: ios swift uialertcontroller