简体   繁体   English

iPhone SDK将视图及其子视图向后移动

[英]iPhone SDK moving a view and its subviews to back

I have an application with multiple views that contain subviews. 我有一个包含多个包含子视图的视图的应用程序。 I know that you can hide or make visible a view and its subviews by setting the hidden property to YES or NO. 我知道您可以通过将hidden属性设置为YES或NO来隐藏或显示视图及其子视图。 However with a number of views, to use the hidden property requires keeping track of what view is being displayed. 但是,对于许多视图,要使用hidden属性,需要跟踪正在显示的视图。 I thought I could use sendSuBViewToBack: to hide a view and moveSubViewToFront to make it visible. 我以为可以使用sendSuBViewToBack:隐藏视图,并使用moveSubViewToFront使其可见。 However, these methods appear to only act on the specific subview and not its child subviews. 但是,这些方法似乎仅作用于特定的子视图,而不作用于其子视图。 For example, a view with a couple of labels on it, when sent to the back, the labels remain visible. 例如,上面有几个标签的视图在发送到背面时,标签仍然可见。

Is there any way to make this behavior work besides using the hidden property? 除了使用hidden属性,还有什么方法可以使这种行为起作用?

Thanks, 谢谢,

Jim 吉姆

UIViewController seems like what you're looking for. UIViewController看起来像您要找的东西。 Or rather, what you should be looking for. 或更确切地说,您应该寻找什么。

I'm not quite sure what exactly you're having trouble with here. 我不太确定您在这里遇到什么困难。 As long as you're keeping track of each "container" view (perhaps using a @property ), you should be able to show/hide them on demand using a method in your code (which can be as simple as hiding all container views, and then showing the one you desire). 只要您跟踪每个“容器”视图(也许使用@property ),就应该能够使用代码中的方法按需显示/隐藏它们(就像隐藏所有容器视图一样简单) ,然后显示您想要的那个)。

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

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