简体   繁体   English

从childviewcontroller访问parentviewcontroller的控制器

[英]Access the controller of parentviewcontroller from childviewcontroller

I am having code in which I have added one childviewcontroller using addsubview. 我正在使用addsubview在其中添加一个childviewcontroller的代码。 Example: 例:

Chidviewcontroller *child=[Chidviewcontroller alloc]intwithnibname:child....];
[parentviewcontroller.view addsubview:child.view];

Now the problem is that when I am working in childviewcontroller: it is not allowed to access any of the parentviewcontroller's object in childviewcontroller Even not allowed to import the Parentviewcontrollerr.h file it showed an error: -UnknownTypeName 现在的问题是,当我在childviewcontroller中工作时:不允许访问childviewcontroller中的任何parentviewcontroller对象,甚至不允许导入Parentviewcontrollerr.h文件,它也会显示错误: -UnknownTypeName

I have read this links . 我已阅读此链接

But it is still not allowed me to import and make the object of parentviewcontroller Please help me how to resolve this and do this 但是仍然不允许我导入并制作parentviewcontroller的对象,请帮助我如何解决此问题并执行此操作

这可能有助于看一看 ,不同之处在于,这里导航到childview,而您又添加了child

u need to navigate to the child class instead of adding it as a subview. 您需要导航到子类,而不是将其添加为子视图。 still if u want to use it as a subview, u need to use delegates to call the methods of the parent class. 还有,如果您想将其用作子视图,则需要使用委托来调用父类的方法。 Let me know if u understood my point of view 让我知道你是否理解我的观点

hope it helps. 希望能帮助到你。 happy coding :) 快乐的编码:)

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

相关问题 parentViewController始终是导航控制器吗? - Is parentViewController always a Navigation controller? 当按下childViewController中的后退按钮时,更改parentViewController中的值 - Change value in parentViewController when back button in childViewController was pressed 从ParentViewController中解除ChildView - Dismiss ChildView From ParentViewController 来自parentViewController的值 - Value from parentViewController 在iPhone开发中,如何在ParentViewController中访问方法 - In iPhone development how to access a method in the ParentViewController iOS:将数据从ChildViewController传递到GrandParentViewController? - iOS: passing data from ChildViewController to GrandParentViewController? 从自定义视图内的UITextFields访问ParentViewController - Accessing ParentViewController from UITextFields inside a custom View 子视图控制器如何使用Parentviewcontroller中定义的方法 - How child view controller can use the method defined in Parentviewcontroller 如何通过parentviewController将数据从一个视图传递到另一个视图 - how to pass data from one view to another view through parentviewcontroller 如何从分页应用程序中的ParentViewController方法调用presentModalViewController - How to call presentModalViewController from ParentViewController Method in paging app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM