Navigation between subview and superview
In my program,I called subview from main superview 开发者_StackOverflowwith the following code: [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.
You can use methods removeFromSuperview and bringSubviewToFront.
It sounds like what you really want is basic navigation bar functionality with a "back" button.
Check out UINavigationController and these two functions
- (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
yes.You can, 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. 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];
精彩评论