Travis M.
Travis M.

Reputation: 11257

Solve Deeply Nested View Controller Hierarchy

This is more of an app design question and not a code specific one.

My problem is that I have an iPhone app that uses a single UINavigationController and a user can tap on data items to push UIViewControllers with more and more detailed information.

Example:

Main Menu -> Category list -> Brand list -> Brand Details -> Product List -> Product Details -> Associated Brands list -> Brand Details -> Products List -> Product Details -> etc

When they want to get back to the main to the main menu they have to hit the back button, like, 10 times. This is obviously a horrible user experience but necessary because of the amount of screen space on the iPhone which requires a lot of supplemental views for my deeply nested data.

How did you guys solve this problem?

I heard that a "hamburger" button / side drawer is the way to go but that was a big "no no" at WWDC 2014 and it causes situations like in the Amazon app where there's both a hamburger and back button at the same time while also displaying only one or the other at various other times.

I was also thinking of possibly tapping on the Navigation bar title to unwind to the main menu but it doesn't seem intuitive to figure out and I haven't seen it used in other apps.

Any advice on how you managed to get around this app design issue would be helpful.

Edit: I know how to unwind and I know how to pop to root. The question is about the "app design". How do you design your app in a way so that your user doesn't have to tap the back button 10 times? I don't want to add a "Go to main menu" button on every view and Apple specifically said side-drawers/hamburger buttons were a bad idea.

Upvotes: 1

Views: 198

Answers (3)

Msencenb
Msencenb

Reputation: 5104

In many ways having deeply nested things aren't necessarily bad 'app design' by Apple's standards as long as the context continues to be the same. Say for example you have an educational app that plays videos. A fairly deep hierarchy could look like this:

View Teacher Page -> View Course By Teacher -> View First Lesson in Course -> View Pop Quiz from the lesson

In this situation the deeply nested navigation controller is an implicit breadcrumb that you see on standard webpages. Everything that is pushed onto the navigation controller stack makes sense in the context of the previous view controller.

Can you give more details about the specific use case here? It's hard to help with such a generic question. Also you might consider checking out UserExperience on StackExchange rather than StackOverflow, which is meant for coding questions specifically.

Upvotes: 2

Kousik
Kousik

Reputation: 22465

Use popToRootViewControllerAnimated to go back to the root viewController.

-(IBAction)backButtonClick:(id)sender {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

Upvotes: 0

Amador Navarro
Amador Navarro

Reputation: 1

If you want navigate to first viewController, you can use popToRootViewControllerAnimated: or you can use popToViewController:animated: in case you want navigate to a specific viewController.

Upvotes: 0

Related Questions