ios - Swift - 单击按钮后打开新 View

标签 ios swift button view

我想在点击一个按钮后打开新 View 。它有效,当我在 Main.storyboard 中通过 UIButton 制作它时,我需要在代码中制作它,因为我必须使用一些带有登录名/密码的 if 语句。我试着让它像其他类似问题中建议的那样,但它不起作用:

@IBAction func login(_ sender: UIButton) {

   performSegue(withIdentifier: "Second", sender: self)} 

登录 View 的Id:第一个

第二个 View 的Id:第二个

enter image description here

最佳答案

您可以使用 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/

相关文章:

ios - aws ios分段上传

ios - UITableViewCell 自动高度不正确,直到我滚动

ios - 如何快速下载文件?

ios - 使用 ECSlidingViewController 时状态栏重叠

javascript - 当用户进入当前网页时,html 5 视频以全屏模式自动打开

swift - CAShapeLayer shadowPath 动画。如何防止动画完成时的阴影填充?

swift - 段错误 : 11 Xcode 10. 1

android - 其他按钮下方的按钮以编程方式android

javascript - 评估语句中的按钮文本

html - 完全不可见的 html 按钮