gpt4 book ai didi

swift - 为什么完成不起作用?完成问题

转载 作者:行者123 更新时间:2023-11-28 13:52:10 25 4
gpt4 key购买 nike

为什么完成不起作用?

警报出现后,它不会过渡到另一个 viewController

self.present(self.alertController2, animated: true, completion:  {                          
self.performSegue(withIdentifier:"goToLogin", sender: self)
})

最佳答案

Self.present 用于将此操作添加到 View 中。您需要将此代码添加到您的 handler handler mean It means what will I will I do when you click OK

let alertbutton = UIAlertAction(title: "OK", style: .destructive, handler: { 
(UIAlertAction) in
self.performSegue(withIdentifier: "your id", sender: self)
})

完整示例:

let alert = UIAlertController(title: "Its empty", message: "Going another view", preferredStyle: .alert)
let alertaction = UIAlertAction(title: "OK", style: .destructive, handler: { (UIAlertAction) in
self.performSegue(withIdentifier: "your segue id", sender: self)
})
alert.addAction(alertaction)
self.present(alert, animated: true, completion: nil)

关于swift - 为什么完成不起作用?完成问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54421496/

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