gpt4 book ai didi

ios - UIAlertController 没有消失

转载 作者:可可西里 更新时间:2023-11-01 03:53:17 26 4
gpt4 key购买 nike

我没有发现我的代码有什么问题。我只是显示带有“确定”按钮的警报,当用户单击“确定”时,警报应该消失。但它并没有消失。使用 Swift3 进行编程。 viewDidAppear() 是放置此代码的正确位置吗?还是我做错了什么?

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

let alertController = UIAlertController(title: "Wrong Item", message: "Could not find details of an item.", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
present(alertController, animated: true, completion: nil)
}

更新:当我将相同的代码放入其他 Controller 时,它起作用了。在原始 Controller 中,在 viewDidLoad() 中,我有一个如下所示的 Async 调用。这个问题是因为那个吗?

DispatchQueue.global(qos: .background).async {
self.getDetails(onCompletion: {(json: JSON) in

let dict = self.convertToDictionary(text: json.stringValue)

DispatchQueue.main.async {

self.activityIndicator.stopAnimating()
UIApplication.shared.endIgnoringInteractionEvents()

//Other UI update operation

}
})
}

我还覆盖了 viewWillDisappear()viewWillAppear(),只是为了设置屏幕标题。

最佳答案

你在调用 UIApplication.shared.beginIgnoringInteractionEvents()
任何地方兄弟??如果是,那是你的问题。

关于ios - UIAlertController 没有消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45530759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com