gpt4 book ai didi

ios - 打开 alertviewcontroller 时显示新的 VC

转载 作者:搜寻专家 更新时间:2023-11-01 05:50:02 24 4
gpt4 key购买 nike

我想显示一个新的 ViewController,但是当显示一个 AlertController 时它不起作用。 (我不想使用现有的 segue,只能快速使用)。有人可以帮助我吗?这只是一个简单的示例,在我的应用程序中,我使用显示加载器的自定义 AlertController。所以,我不想在点击警报按钮后被重定向

提前致谢

Ps:抱歉我的英语不好。

@IBAction func testButtonClick(_ sender: AnyObject) {
let alert = UIAlertController(title: nil, message: "test", preferredStyle: UIAlertControllerStyle.alert)
self.present(alert, animated: true, completion: nil)
logout()
}

func logout() {
let storyboardName = "Authentication"
let storyboard = UIStoryboard(name: storyboardName, bundle: nil)
if let newVC = storyboard.instantiateInitialViewController() {
newVC.modalPresentationStyle = UIModalPresentationStyle.fullScreen
self.present(newVC, animated: true)
} else {
print("Unable to instantiate VC from \(storyboardName) storyboard")
}
}

最佳答案

可以这样使用。

let alert = UIAlertController(title: nil, message: "test", preferredStyle: UIAlertControllerStyle.alert)
self.present(alert, animated: true, completion: nil)

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let newVC = storyboard.instantiateViewController(withIdentifier: "ChildViewController") as? ChildViewController


newVC?.modalPresentationStyle = UIModalPresentationStyle.fullScreen

presentedViewController?.present(newVC!, animated: true)

关于ios - 打开 alertviewcontroller 时显示新的 VC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42928076/

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