【问题标题】:swift Navigate between two view controllers在两个视图控制器之间快速导航
【发布时间】:2015-08-05 09:35:09
【问题描述】:
@IBAction func goView1(sender: AnyObject) {
    let view1 = self.storyboard.instantiateViewControllerWithIdentifier("view1") as ViewController
}

给出错误:

Value of optional type 'UIStoryboard' not unwrapped; did you mean to use '!' or '?' ?

请帮帮我

【问题讨论】:

    标签: swift navigation uistoryboard


    【解决方案1】:
     let view1 = self.storyboard.instantiateViewControllerWithIdentifier("ViewControllerIentifier") as? ViewControllerName
    

    这将解决您的问题

    【讨论】:

    • self.navigationController.presentViewController(view1, animated: true, completion: nil);还有一些错误
    【解决方案2】:

    这样你可以实例化和展示一个新的viewController

    @IBAction func goView1(sender: AnyObject) {
    
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("view1") as! UIViewController
        self.presentViewController(vc, animated: true, completion: nil)
    
    }
    

    更多信息请查看THIS教程。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-02
      • 2014-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-16
      相关资源
      最近更新 更多