同一 window 中的两个弹出警报
Two pop up alerts in same window
我正在尝试在同一个 window、
中获得两个弹出警报
但是有了第二个警报功能,程序运行但是当点击按钮时,崩溃并报错
错误:libc++abi.dylib:以 NSException
类型的未捕获异常终止
@IBAction func buttonPressed(sender: UIButton) {
let title = "Display Title"
let message = "You just clicked on Display Alert"
let okText = "OK"
let title1 = "Display Title"
let message1 = "You just clicked on Display Alert"
let okText1 = "OK"
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
let okayButton = UIAlertAction(title: okText, style: UIAlertActionStyle.Cancel, handler: nil)
alert.addAction(okayButton)
let alert1 = UIAlertController(title: "title1", message: "message1", preferredStyle: UIAlertControllerStyle.Alert)
let okayButton1 = UIAlertAction(title: okText1, style: UIAlertActionStyle.Cancel, handler: nil)
alert.addAction(okayButton1)
presentViewController(alert, animated: true, completion: nil)
presentViewController(alert1, animated: true, completion: nil)
}
您一次只能显示一个 UIAlertController。
您可以使用 TKSwarmAlert 自定义控件,但不会有关闭按钮。
我正在尝试在同一个 window、
中获得两个弹出警报但是有了第二个警报功能,程序运行但是当点击按钮时,崩溃并报错
错误:libc++abi.dylib:以 NSException
类型的未捕获异常终止@IBAction func buttonPressed(sender: UIButton) {
let title = "Display Title"
let message = "You just clicked on Display Alert"
let okText = "OK"
let title1 = "Display Title"
let message1 = "You just clicked on Display Alert"
let okText1 = "OK"
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
let okayButton = UIAlertAction(title: okText, style: UIAlertActionStyle.Cancel, handler: nil)
alert.addAction(okayButton)
let alert1 = UIAlertController(title: "title1", message: "message1", preferredStyle: UIAlertControllerStyle.Alert)
let okayButton1 = UIAlertAction(title: okText1, style: UIAlertActionStyle.Cancel, handler: nil)
alert.addAction(okayButton1)
presentViewController(alert, animated: true, completion: nil)
presentViewController(alert1, animated: true, completion: nil)
}
您一次只能显示一个 UIAlertController。
您可以使用 TKSwarmAlert 自定义控件,但不会有关闭按钮。