[英]View based delegation in storyboards and UITabbarController
I know this has been asked, but I can't figure out how to make this work with my app -- I'm sure I'm doing it wrong. 我知道有人问过这个问题,但是我不知道该如何使用我的应用程序进行这项工作-我确定我做错了。
I have two view controllers embedded inside a UITabBarViewContoller
, FirstViewController
and SecondViewController
. 我在UITabBarViewContoller
嵌入了两个视图控制器, FirstViewController
和SecondViewController
。 SecondViewController
is nothing more then a few UITextFields
for managing a hostname and port that the app connects to. SecondViewController
就是一些用于管理应用程序连接到的主机名和端口的UITextFields
。
FirstViewController contains most of the code (which I know isn't very MVC oriented). FirstViewController包含大多数代码(我知道它不是非常面向MVC的)。 I'm trying to implement Delegation from SecondViewController
back to FirstViewController
( Passing Data between View Controllers ) but it seems like my delegate methods aren't being called. 我试图实现从SecondViewController
到FirstViewController
( 在View Controllers之间传递数据 ),但似乎未调用我的委托方法。 Since this is based on storyboards, I'm not creating the instance of SecondViewController
and I'm not sure how to set the Delegate. 由于这是基于情节SecondViewController
,因此我没有创建SecondViewController
的实例,也不确定如何设置Delegate。 Is there a way to access the instance of SecondViewController
so I can set the Delegate? 有没有一种方法可以访问SecondViewController
的实例,以便我可以设置Delegate?
milesper thank you! 哩程谢谢!
My solution (in swift) 我的解决方案(迅速)
let secondView = self.tabBarController.viewControllers[1] as SecondViewController
secondView.delegate = self
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.