【发布时间】:2022-07-04 23:23:15
【问题描述】:
我有一个包含多个选项卡栏项目的应用程序,在一个特定屏幕中,如果用户单击另一个栏按钮选项卡,我会尝试停止一些正在运行的功能(因为我只想仔细检查它们是否真的是他们想要做的)。问题是当用户单击另一个选项卡栏按钮时,屏幕会转到该视图控制器,然后显示警报。
有没有办法暂停它,以便仅在用户解决警报后才发生转场?
override func viewDidDisappear(_ animated: Bool) {
//asking if want to cancel the workout?
let alert = UIAlertController(title: "Leaving?", message: "The data wont be saved if you leave now, are you sure you want to leave?", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Yes", style: UIAlertAction.Style.default, handler: nil))
alert.addAction(UIAlertAction(title: "No", style: UIAlertAction.Style.default, handler: nil))
self.present(alert, animated: true, completion: nil
}
【问题讨论】:
标签: ios swift uialertcontroller