简体   繁体   English

touchesbegan在第二个viewcontroller的子视图上不起作用

[英]touchesbegan doesn't work on subview from second viewcontroller

I'm developing an iPhone app and I am trying to solve the following problem. 我正在开发iPhone应用程序,正在尝试解决以下问题。 In my main viewcontroller view I add the view of an other viewcontroller as subview. 在我的主viewcontroller视图中,我将另一个viewcontroller的视图添加为子视图。 But the touchesbegan function of the other viewcontroller doesn't respond to the touches. 但是另一个视图控制器的touchesbegan函数不响应触摸。 What is the best way to fix this problem? 解决此问题的最佳方法是什么?

Not sure what you are doing this but adding views of one controller as a subview is another has been discouraged since iOS 5. In iOS 5 you can contain UIViewController s within each other using the addChildViewController method. 自iOS 5以来,不确定要执行的操作,但不鼓励将一个控制器的视图作为子视图添加到另一个视图中。在iOS 5中,可以使用addChildViewController方法将UIViewController彼此包含在内。 This answer provides a bit insight into the matter. 这个答案提供了对此事的一些见识。

Update Apple's Documentation on containment. 更新有关收容措施的Apple文档

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

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