Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cthesky

macrumors member
Original poster
Aug 21, 2011
91
0
Hi all,

I really need some help and suggestions about organize the view hierarchy in my education app.

In my app, it consists some view controllers as below:

1. Menu View Controller - consists level buttons example: 'Level 1', 'Level 2'.

2. Level View Controller - show the questions for each level.
For example: When user click 'Level 1' button in Menu View Controller, this level view controller will show a view and display a number of questions let user answer.

3. Result View Controller - show the result once user finish answer the questions.

In this result view controller, it consists
(a) 'Play Again' button - Once click it, will switch back to Level View Controller so user can play again.
(b) 'Back to Menu' button - Once press it, it will switch back to menu view controller.
(c) 'Play Next Level' button - When click it, it will switch to Level View Controller which will show different set of questions.

I am not sure how to organize these view controller in a better way since it always need switch between the existing view controllers. Before this I am adding a view controller as a subview of another view controller to achieve 'switch view' purpose but it seems not a good practice. Am I need use navigation controller?

Currently I am reading the view controller programming guide. But really hope someone can share their idea, suggestion and experience.

Any comments are welcome. Thanks a lot. :)
 

Reason077

macrumors 68040
Aug 14, 2007
3,606
3,644
I am not sure how to organize these view controller in a better way since it always need switch between the existing view controllers. Before this I am adding a view controller as a subview of another view controller to achieve 'switch view' purpose but it seems not a good practice. Am I need use navigation controller?

Yes, UINavigationController is probably what you want to use here, if you want standard iPhone-style sliding transitions between your menu and each level.

You should also look into Storyboards. They're a good way to set up this sort of navigation without much coding:

http://mobile.tutsplus.com/tutorials/iphone/ios-5-sdk-storyboards/
 

cthesky

macrumors member
Original poster
Aug 21, 2011
91
0
Yes, UINavigationController is probably what you want to use here, if you want standard iPhone-style sliding transitions between your menu and each level.

You should also look into Storyboards. They're a good way to set up this sort of navigation without much coding:

http://mobile.tutsplus.com/tutorials/iphone/ios-5-sdk-storyboards/

Thanks for your reply. :)

If use UINavigationController I may need hide the navigation bar in Menu and Result View Controller and display most of the buttons example level buttons in UIButton form instead of the navigation bar button. Am I right?

Yes, storyboard is quite helpful but I heard it may not run in previous version IOS device. Am I right?
 

Reason077

macrumors 68040
Aug 14, 2007
3,606
3,644
If use UINavigationController I may need hide the navigation bar in Menu and Result View Controller and display most of the buttons example level buttons in UIButton form instead of the navigation bar button. Am I right?

Yeah, if you don't want a navigation bar, you can do it that way.

Yes, storyboard is quite helpful but I heard it may not run in previous version IOS device. Am I right?

It works in iOS 5.0 and up. Probably 98%+ of active iOS users are using iOS 5 and up already, so I would not worry about this.
 

cthesky

macrumors member
Original poster
Aug 21, 2011
91
0
Yeah, if you don't want a navigation bar, you can do it that way.



It works in iOS 5.0 and up. Probably 98%+ of active iOS users are using iOS 5 and up already, so I would not worry about this.

I see. Thanks for your help.

But I have some questions regarding the navigation controller.

1. If use navigation controller, how to pop out more than one view controller ? Let's say I need go 2 steps back. For example, in my app I know how to switch from result view controller back to level view controller but not sure how to switch from result view controller back to menu view controller.

2. If I need include navigation bar in some of the view controllers only, so can I just hide the navigation bar when I don't want it and show it again if I need it to be seen ? Am I correct?

Thanks. :)
 

Reason077

macrumors 68040
Aug 14, 2007
3,606
3,644
1. If use navigation controller, how to pop out more than one view controller ? Let's say I need go 2 steps back. For example, in my app I know how to switch from result view controller back to level view controller but not sure how to switch from result view controller back to menu view controller.

I think it's possible to call popViewController twice if you want to go up two levels in the stack.

But the better way is to use:

popToViewController:animated: to go to a specific ViewController on the stack,
or popToRootViewControllerAnimated: to go all the way to the root viewController.

2. If I need include navigation bar in some of the view controllers only, so can I just hide the navigation bar when I don't want it and show it again if I need it to be seen ? Am I correct?

Sure. Calling setNavigationBarHidden:YES animated:YES in the viewWillAppear (and, perhaps, the opposite in viewWillDisappear) of the appropriate viewController should do the right thing.
 

cthesky

macrumors member
Original poster
Aug 21, 2011
91
0
I think it's possible to call popViewController twice if you want to go up two levels in the stack.

But the better way is to use:

popToViewController:animated: to go to a specific ViewController on the stack,
or popToRootViewControllerAnimated: to go all the way to the root viewController.



Sure. Calling setNavigationBarHidden:YES animated:YES in the viewWillAppear (and, perhaps, the opposite in viewWillDisappear) of the appropriate viewController should do the right thing.

Hi, Thanks ! You really help me a lot. :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.