Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 2, 2012, 04:21 AM   #1
cthesky
macrumors member
 
Join Date: Aug 2011
Help. About organize view hierarchy in an app.

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.
cthesky is offline   0 Reply With Quote
Old Nov 2, 2012, 05:23 AM   #2
Reason077
macrumors 65816
 
Join Date: Aug 2007
Quote:
Originally Posted by cthesky View Post
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...k-storyboards/
Reason077 is offline   0 Reply With Quote
Old Nov 2, 2012, 05:57 AM   #3
cthesky
Thread Starter
macrumors member
 
Join Date: Aug 2011
Quote:
Originally Posted by Reason077 View Post
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...k-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?
cthesky is offline   0 Reply With Quote
Old Nov 2, 2012, 08:35 AM   #4
Reason077
macrumors 65816
 
Join Date: Aug 2007
Quote:
Originally Posted by cthesky View Post
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.

Quote:
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.
Reason077 is offline   0 Reply With Quote
Old Nov 5, 2012, 05:46 AM   #5
cthesky
Thread Starter
macrumors member
 
Join Date: Aug 2011
Quote:
Originally Posted by Reason077 View Post
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.
cthesky is offline   0 Reply With Quote
Old Nov 5, 2012, 07:31 AM   #6
Reason077
macrumors 65816
 
Join Date: Aug 2007
Quote:
Originally Posted by cthesky View Post
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.

Quote:
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.
Reason077 is offline   0 Reply With Quote
Old Nov 5, 2012, 10:14 AM   #7
cthesky
Thread Starter
macrumors member
 
Join Date: Aug 2011
Quote:
Originally Posted by Reason077 View Post
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.
cthesky is offline   0 Reply With Quote
Old Nov 5, 2012, 10:21 AM   #8
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Be sure you've read the View Controller Programming Guide (something I suggested previously in another thread of yours).
__________________
dejo is offline   0 Reply With Quote
Old Nov 5, 2012, 10:40 AM   #9
cthesky
Thread Starter
macrumors member
 
Join Date: Aug 2011
Quote:
Originally Posted by dejo View Post
Be sure you've read the View Controller Programming Guide (something I suggested previously in another thread of yours).
Yes, I know it and is reading. Thanks.
cthesky is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
App to best organize pictures? Pete Sahut iPad Apps 4 Jan 6, 2014 02:47 PM
Looking for an app to organize my photos simeezee iPhone and iPod touch Apps 0 Feb 17, 2013 04:43 AM
Is there an app that will play any video format and organize playlist? yalag iPhone and iPod touch Apps 12 Feb 4, 2013 05:19 AM
iMac Upgrade hierarchy nagareru iMac 3 Dec 1, 2012 11:17 PM
Any apps that let me save we pages to view offline, and organize them into files? Oragami iPad Apps 0 Oct 3, 2012 09:49 PM

Forum Jump

All times are GMT -5. The time now is 06:40 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC