简体   繁体   English

如何回到iOS的Superview

[英]How to go back to the superview in ios

To view1 I added a sub view (view2). 为了给view1添加一个子视图(view2)。 And now I am in view2, Now I wanted to move back to view1. 现在我进入了view2,现在我想回到view1。 I am using [self.view removefromsuperview] but it is not working. 我正在使用[self.view removefromsuperview]但无法正常工作。

You aren't supposed to organise your application as views that you add on top of one another. 您不应该将应用程序组织为彼此叠加的视图。 A more typical way of organising your application is to split the different screens into different view controllers and use a UINavigationController to navigate between them. 组织应用程序的一种更典型的方法是将不同的屏幕拆分为不同的视图控制器,并使用UINavigationController在它们之间进行导航。

If you just lump all your code together into a single view controller and manually add and remove views, you're going to get into a mess very quickly. 如果只是将所有代码集中到一个视图控制器中,然后手动添加和删除视图,那么您将很快陷入混乱。 I strongly recommend reading View Controller Programming Guide for iOS . 我强烈建议阅读《适用于iOS的View Controller编程指南》

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

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