ios - 在 UIViewContriller Swift 5 中的 func viewDidLoad() 之后运行 UIAlertController
问题描述
我需要在加载视图后立即显示警报。此代码被忽略。如何获得此警报?
class TrailerViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if gConnected == false{
let alert = UIAlertController(title: "Wifi Not Connected", message: "The Wifi is not connected to the Trailer Expert.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Connect", style: .default, handler: connectWifi()))
alert.addAction(UIAlertAction(title: "Ignore", style: .cancel, handler: nil))
self.present(alert, animated: true)
}
// Do any additional setup after loading the view, typically from a nib.
}
解决方案
推荐阅读
- r - 无法安装 locfit r 软件包
- r - 使用 scale_x_continuous 时如何修复 ggplot 中的轴文本重叠问题
- c# - 从下拉角度中删除选定的值
- firebase - 有没有办法从 Firebase 中删除有关用户的所有数据?
- c - Linux系统如何处理文件中的CRLF?
- javascript - 使用javascript从json数据中简单地生成图表的最佳方法是什么?
- python - 使用 Python 将 1562008049.727648 转换为 156200
- python - 有没有办法通过对 2 张图像进行颜色处理来突出图像差异?
- eclipse - Eclipse Aptana 3 - 没有语法高亮(黑白编辑器代码)
- swiftui - 如何使用导航项内的导航按钮进行导航?SwifitUI