繁体   English   中英

在故事板和UITabbarController中基于视图的委派

[英]View based delegation in storyboards and UITabbarController

我知道有人问过这个问题,但是我不知道该如何使用我的应用程序进行这项工作-我确定我做错了。

我在UITabBarViewContoller嵌入了两个视图控制器, FirstViewControllerSecondViewController SecondViewController就是一些用于管理应用程序连接到的主机名和端口的UITextFields

FirstViewController包含大多数代码(我知道它不是非常面向MVC的)。 我试图实现从SecondViewControllerFirstViewController在View Controllers之间传递数据 ),但似乎未调用我的委托方法。 由于这是基于情节SecondViewController ,因此我没有创建SecondViewController的实例,也不确定如何设置Delegate。 有没有一种方法可以访问SecondViewController的实例,以便我可以设置Delegate?

哩程谢谢!

我的解决方案(迅速)

    let secondView = self.tabBarController.viewControllers[1] as SecondViewController
    secondView.delegate = self

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM