2017-03-08 29 views
1

但是,我没有收到第二个视图控制器中的数据......我在这里做错了什么?使用InstantiateViewController传递数据

 let storyboard = UIStoryboard(name: "PostSubmit", bundle: nil) 
     let vc = storyboard.instantiateViewController(withIdentifier: "PostSubmitVC") as! PostSubmitViewController { 
      let nc = UINavigationController(rootViewController: vc) 
      vc.filteredResult = filteredResult 
     } 
     self.present(nc, animated: false, completion: nil) 
+0

在通过它之前打印'filteredResult'。也许它是零。 – Sweeper

回答

1

可能是问题是你错了呈现控制器nc值已设置为块内,它不可了侧块。

let vc = storyboard.instantiateViewController(withIdentifier: "PostSubmitVC") as! PostSubmitViewController 
let nc = UINavigationController(rootViewController: vc) 
vc.filteredResult = filteredResult 
self.present(nc, animated: false, completion: nil) 
+0

是的,这是人,谢谢你的帮助!对此,我真的非常感激。看起来像它总是那么小,我看起来很小。我今天简直把我的代码撕成了这么小的东西。大声笑 – Denis

+0

@Denis欢迎队友:) –

+0

我的坏家伙,我试图发布这个问题。 http://stackoverflow.com/questions/42607702/line-chart-in-swift-3但感谢提醒。任何对此的帮助都会很棒。它来自另一个来源,但我很难将其转换为swift 3 – Denis