Reputation: 555
Say you have a project that you started as a "Tabbed Application", which creates two tabbed Views by default. Now, you have another NIB that is separate from these Tabs (that is, you don't want it to be a part of tab items, and you have it as a separate set of .m, .h, .xib files).
How do you bring this View to the front? And then how do you hide it?
Upvotes: 0
Views: 58
Reputation: 2921
If you want to add another view to UIViewController:
Files: View.h
, View.m
, View.xib
In View.h:
@property (retain, nonatomic) UIView *customView;
In View.m:
#import "View.h"
- (void)addSubView
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"View" owner:nil options:nil];
self.customView = nib[0];
[self.view addSubview:self.customView];
}
- (void)removeSubView
{
[self.customView removeFromSuperView];
}
Upvotes: 0
Reputation: 29064
Use the function called bringSubviewToFront
Example: [self.view bringSubviewToFront:newView];
Upvotes: 1