简体   繁体   English

访问添加在情节提要上的ViewController的子视图

[英]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.

相关问题 没有情节提要时实例化ViewController - Instantiating a ViewController when there's no storyboard 为什么UITableView不会获得任何用户交互,因为它的ViewController作为subView添加到UITabBarController - Why UITableView is not getting any user interaction as it's ViewController is added to a UITabBarController as subView 将新的Viewcontroller视图添加为子视图 - Adding new Viewcontroller's view as subview 转换时UIPageViewController的viewController子视图动画 - UIPageViewController's viewController subview animation on transition 导航控制器的视图作为ViewController中的子视图 - Navigation Controller's view as a subview in a ViewController 通过另一个ViewController访问ViewController的变量 - Accessing ViewController's variables through another ViewController 自定义ViewController转换:获取ToViewController的子视图框架 - Custom ViewController Transitions: Get ToViewController's Subview's Frame 从其视图的子视图调用ViewController的方法? - Calling ViewController's method from its view's subview? 使用AutoLayout(故事板)自动调整UIView的高度到它的子视图 - Automatically Adjust UIView's Height to It's Subview using AutoLayout (Storyboard) 情节提要将viewcontroller的视图添加到另一个viewcontroller iOS5 +中 - Storyboard add viewcontroller's view into another viewcontroller iOS5+
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM