如何更新 swift 中的当前警报视图标题?
How to update current alertview title in swift?
我使用 "UIAlertController" & "presentViewController" 来显示警报视图,如下所示
let deviceName = bleManager.activePeripheral?.name
let alert = UIAlertController(title: "Connecting...", message: deviceName, preferredStyle: UIAlertControllerStyle.Alert)
presentViewController(alert, animated: true, completion: nil)
现在我想将当前标题从 "Connecting" 更新为 "Searching",但是 alertview 无法关闭。
怎么做?
您可以将警报 object 存储在 属性 中,并在需要时访问和更新它。
这包括更改标题或添加操作。
我使用 "UIAlertController" & "presentViewController" 来显示警报视图,如下所示
let deviceName = bleManager.activePeripheral?.name
let alert = UIAlertController(title: "Connecting...", message: deviceName, preferredStyle: UIAlertControllerStyle.Alert)
presentViewController(alert, animated: true, completion: nil)
现在我想将当前标题从 "Connecting" 更新为 "Searching",但是 alertview 无法关闭。
怎么做?
您可以将警报 object 存储在 属性 中,并在需要时访问和更新它。
这包括更改标题或添加操作。