[英]Accessing a ViewController's subview that's added on the storyboard
Please see the image below for a storyboard visual. 请查看下面的图片以获得演示图板的视觉效果。 I have a ViewController called StudioViewController (It's labeled ViewController on the storyboard).
我有一个称为StudioViewController的ViewController(在情节提要板上标记为ViewController)。 And I have a UIScrollView that's called CanvasViewController (the thing to the right of the view controller that actually sits on top of the View Controller).
我有一个名为CanvasViewController的UIScrollView(实际上位于视图控制器顶部的视图控制器右侧的东西)。 I want to be able to access the CanvasViewController in the StudioViewController class, how do I do that?
我希望能够访问StudioViewController类中的CanvasViewController,该怎么做? Because I created it in the storyboard here, I dont' seem to have a variable that allows me to access the CanvasViewController... Should I create it in code instead, or is there some obvious way to access it that I'm completely missing?
因为我是在这里的情节提要中创建的,所以似乎没有一个变量可以让我访问CanvasViewController ...应该改为在代码中创建它,还是可以通过某种明显的方式来访问它,而我却完全没有了?
Thanks 谢谢
******** UPDATE ********* ********更新*********
The question has been answered in the comments below by rdelmar: rdelmar在下面的评论中回答了这个问题:
You could make a shared variable in the app delegate. 您可以在应用程序委托中创建一个共享变量。 This is not very secure but I have resulted to this when I can't access a child or parent due to page transitions.
这不是很安全,但是由于页面转换而导致我无法访问孩子或父母时,导致了这种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.