Lou*_*uis 1 uiviewcontroller ios swift swift3
我想显示一个新的ViewController,但是当显示AlertController时它不起作用.(我不想使用现有的segue,只能在swift中使用).有人可以帮帮我吗?这只是一个简单的例子,在我的应用程序中我使用了一个显示加载器的自定义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")
}
}
Run Code Online (Sandbox Code Playgroud)
你可以这样使用.
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)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
374 次 |
最近记录: |