Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested UINavigationController

I'm fairly new to iOS development and I want to make something like the attached screenshot.

enter image description here

I've read the nested UINavigationControllers is not a good idea, if not impossible, so I'm more than willing to accept ideas on how to implement what I want.

On my second screen there are two views I want to switch back and forth between (NOT using gestures and push animated), while maintaining a static header and footer.

The only way I know how to do a push segue is with a UINavigationController, hence why I see the need for nested ones.

How do I implement this? I thought that in my second UIViewController I could programmatically create a UINavigationController and add it to self.view, but I ended up doing this:

self.subNavigationController = [UINavigationController alloc] initWithRootViewController:[someVC alloc] init]];
[self.view addSubview: self.subNavigationController.view]

But that only adds the view of self.subNavigationController to self.view, not self.subNavigationController itself.

Like I said, I could easily be way off base on how I should be handling it, any advice is appreciated.

like image 902
Adam Avatar asked Mar 08 '26 02:03

Adam


1 Answers

OK, if I've got this right then what you want is an app where you can navigate between different views (like any other app).

This will use a UINavigationController (lets call this "nav1") and this is the bit that you're OK with.

However, you also want a view that will have a static navigation bar. i.e. as far as nav1 is concerned this is only a single part of the navigation through the app. It also wants to have two potential views in there. (the map and the table view) and it will have a static bar along the bottom too (in IB this is a ToolBar I think). Lets call this the "mapAndTableViewController".

You haven't said exactly how this works but you don't want swipe gestures between them. So I'm guessing you will have a button or something to swap between them?

Something like this...

http://www.youtube.com/watch?v=eg6vWGh67zk&feature=youtube_gdata_player

The way I've done this is to use a single view controller with a scroll view. On the scrollview set scrolling disabled and set paging enabled. This sounds odd but this removes the touch scrolling from the scrollview while still allowing code access.

Now, in the mapAndTableViewController you populate the left and the right hand side of the scroll view.

What you do here is now take the two view controllers... mapViewController and yourTableViewController and instantiate them. Then add the views of these controllers in to the scrollview left and right sides accordingly.

Essentially you will have THREE view controllers. One for the scroll view, one for the map view and one for the table view.

Without any further explanation from you I can't really help beyond this as I don't fully understand what it is you're trying to achieve.

Hope this helps...

like image 116
Fogmeister Avatar answered Mar 10 '26 20:03

Fogmeister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!