我想在点击一个按钮后打开新 View 。它有效,当我在 Main.storyboard 中通过 UIButton 制作它时,我需要在代码中制作它,因为我必须使用一些带有登录名/密码的 if 语句。我试着让它像其他类似问题中建议的那样,但它不起作用:
@IBAction func login(_ sender: UIButton) {
performSegue(withIdentifier: "Second", sender: self)}
登录 View 的Id:第一个;
第二个 View 的Id:第二个
最佳答案
您可以使用 Storyboard ID
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "secondStoryboardId") as! SecondViewController
self.present(nextViewController, animated:true, completion:nil)
关于ios - Swift - 单击按钮后打开新 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45139355/