gpt4 book ai didi

ios - 在 iOS 9 的 alert.addAction 中按下 OK 时如何打开另一个 View Controller

转载 作者:搜寻专家 更新时间:2023-11-01 06:07:25 26 4
gpt4 key购买 nike

当按下 add.alertAction 中的“确定”时,我想显示一个名为 InViewController 的 View Controller 。

if ((user) != nil) {               
let alert = UIAlertController(title: "Success", message: "Logged In", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in })
self.presentViewController(alert, animated: true){}
}

最佳答案

let alert = UIAlertController(title: "Success", message: "Logged In", preferredStyle: .Alert)
let action = UIAlertAction(title: "OK", style: .Default) { (action) -> Void in
let viewControllerYouWantToPresent = self.storyboard?.instantiateViewControllerWithIdentifier("SomeViewControllerIdentifier")
self.presentViewController(viewControllerYouWantToPresent!, animated: true, completion: nil)
}
alert.addAction(action)
self.presentViewController(alert, animated: true, completion: nil)

关于ios - 在 iOS 9 的 alert.addAction 中按下 OK 时如何打开另一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33725721/

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