gpt4 book ai didi

ios - UIAlertView 显示警报显示晚于需要 ios

转载 作者:搜寻专家 更新时间:2023-10-30 22:26:33 24 4
gpt4 key购买 nike

我正在使用 UIAlertView 显示警报,它是第一次工作,当我点击警报时出现,但是当我第二次这样做时,点击两次警报显示,而不是第一次点击。

在接下来的时间里,“visited full”在第一次点击时打印出来,但在第二次点击时出现警告,为什么会出现这种情况?请帮我解决。提前致谢

println("visited full")
var alert:UIAlertView = UIAlertView(title: "Video", message: "You have played all videos", delegate: self, cancelButtonTitle: "OK")
alert!.show()

最佳答案

如果它不起作用,那么试试这个可能会起作用。

let alert = UIAlertController(title: "Video", message: "You have played all videos", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)

编辑:我想你也可以这样使用它:

dispatch_async(dispatch_get_main_queue(), {
var alert:UIAlertView = UIAlertView(title: "Video", message: "You have played all videos", delegate: self, cancelButtonTitle: "OK")
alert.show()
})

UIAlertController

dispatch_async(dispatch_get_main_queue(), {
let alert = UIAlertController(title: "Video", message: "You have played all videos", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
})

关于ios - UIAlertView 显示警报显示晚于需要 ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26883804/

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