Lory Huz
Lory Huz

Reputation: 1508

How to have a subview displayed in all controller ? Like a navbar

I want to create a kind of navigation bar but without the navigation bar element. So I created a view controller with his xib. it's like a footer. I want this footer to be displayed in the entire app. But when I switch view with the navigation controller, this footer is reallocated and is being part of the transition animation. Logic because I init this footer in all Views Controller.

I would like to have the same display as a navigation bar (a bottom bar persistent in the app). How I could do it and where ?

Here is how I start my app:

LHHomeViewController *rootViewController = [[LHHomeViewController alloc] initWithNibName:@"LHHomeViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc]  initWithRootViewController:rootViewController];

[nav setNavigationBarHidden:YES animated:NO];
self.window.rootViewController = nav;

Upvotes: 0

Views: 46

Answers (2)

Liam
Liam

Reputation: 12668

Have a read of the View Controller Programming Guide.

Essentially you want to create some sort of UIViewController subclass where you house your custom bottom bar but you also initialise it with a rootViewController which could be your NavigationController.

You would then position the rootViewController and your custom bottom bar inside your view controller subclass to get the desired layout.

Upvotes: 0

demonofthemist
demonofthemist

Reputation: 4199

Create a custom UINavigationController class file & assign this class to your UINavigationController as you do with normal UIViewController.

Then write your code for custom nav bar here & add it to view of Navigation controller using [self.view addSubview:view_to_add] method. By using this you can keep your view on top all the times.

Upvotes: 1

Related Questions