2015-11-04 77 views
0

我有以下问题:如何从NavigationController将值推送到rootViewController?

我想通过Popover中的UINavigationController将一些数据传递给我的rootViewController。我酥料饼是在这里:

var popoverNavigationController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("popoverNavigationController") as! PopoverNavigationController 

生病时打开该控制器:

popoverController.modalPresentationStyle = UIModalPresentationStyle.Popover 
self.presentViewController(popoverController, animated: true, completion: nil) 

有一个RootViewController的,具有一定的阶级 - 我怎么可能追加从NavigationController数据,其RootViewController的?

例如:

popoverController.text = "1234" 

我怎么能推动这个值到RootViewController的? NavigationController由Storyboard初始化。

在此先感谢。

enter image description here

+0

你能解释一下你的层次的ViewController多一点?也许显示一个图像或东西?我有点困惑... :) –

+0

谢谢 - 添加图像。这里的问题是,Popover视图控制器直接从故事板加载,而不是用segue加载。 – derdida

+0

也许是完整的屏幕? :)然后再告诉我你想从哪个vc传递数据到哪个vc? –

回答

1

如果我就在你navigationcontroller得到了你,你可以做这样的事情:

if let rootViewController = viewControllers.first as? PopoverAddItemsViewController { 
    rootViewController.text = "1234" 
} 
+0

谢谢,这工作正常! – derdida

相关问题