Leonardo DaVintik
Leonardo DaVintik

Reputation: 555

How to switch Views in tabbed app on iOS6?

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

Answers (2)

pbibergal
pbibergal

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

lakshmen
lakshmen

Reputation: 29064

Use the function called bringSubviewToFront

Example: [self.view bringSubviewToFront:newView];

Upvotes: 1

Related Questions