无法实例化并推送到另一个视图控制器

时间:2016-08-04 08:54:04

标签: swift pushviewcontroller presentviewcontroller

我有集合视图,如果选择了单元格,则下载pdf文件。下载完成并再次选择单元格后,它将推送到另一个视图控制器。但它没有推动,有人可以解释为什么吗?

这是我的代码

if self.percentProgressFinal == 1.0 { //download complete
     print("SUCCESS")
     let storyboard = UIStoryboard(name: "Main", bundle: nil)
     let vc = storyboard.instantiateViewControllerWithIdentifier("NEXT")
      self.navigationController?.pushViewController(vc, animated: true)
} else {
      print("still downloading")
}

成功打印“SUCCESS”但代码不会执行。我也尝试使用礼物和本

    let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let nextViewController: redirectMagazineViewController = storyBoard.instantiateViewControllerWithIdentifier("NEXT") as! redirectMagazineViewController // my second view controller name   
    self.navigationController?.pushViewController(nextViewController, animated: true)

仍然无法正常工作。我确定我的故事板ID是“NEXT”。

2 个答案:

答案 0 :(得分:1)

好像你没有嵌入导航控制器。

enter image description here

答案 1 :(得分:0)

您是否在Identity Inspector视图控制器上选中了“使用storyboard id”按钮?

相关问题