简体   繁体   English

在子视图和超级视图之间导航

[英]Navigation between subview and superview

In my program,I called subview from main superview with the following code: [self.viewaddSubview:mysubView.view]; 在我的程序中,我使用以下代码从主超级视图调用了子视图:[self.viewaddSubview:mysubView.view]; I want to navigate from subview to previous superview like 'back function'.How can do like that? 我想从子视图导航到上一个超级视图,例如“后退功能”。该怎么办? For My project,I use xCode 3.0. 对于我的项目,我使用xCode 3.0。

您可以使用方法removeFromSuperview和BringSubviewToFront。

It sounds like what you really want is basic navigation bar functionality with a "back" button. 听起来您真正想要的是带有“后退”按钮的基本导航栏功能。

Check out UINavigationController and these two functions 查看UINavigationController和这两个功能

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated

and

- (UIViewController *)popViewControllerAnimated:(BOOL)animated

at this documentation page: 在此文档页面上:

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html

yes.You can, sendSubviewToBack: 是的。您可以发送sendSubviewToBack:

[self.view sendSubviewToBack:mysubView.view];

or 要么

[mysubView.view removeFromSuperview];

You must get the object of subview in superView and store them into an array and than remove them according to there index position. 您必须在superView中获取subview的对象并将其存储到数组中,然后根据那里的索引位置将其删除。 If you use only single subview in super view than follow this code : 如果您仅在超级视图中使用单个子视图,则请遵循以下代码:

NSArray *arr = [SuperView subviews];

NSLog ("objects in arr %@",arr);

[[arr objectAtIndex:0] removeFromSuperview];

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

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