Reputation: 149
I'm trying to build an educational app that will have approximately 3-5 completely different pages/screens. Each screen contains one puzzle and each puzzle is independent of all the other puzzles (screens). Once the puzzle on the current screen is solved I'd like to transition to a new (randomly selected) screen. I would allow the same puzzle to be shown multiple times, however, if it had been displayed before it would need to be reset.
I've tried doing this using segues but that seems to require a UINavigationController which is not the experience I want to present (since it requires a predefined hierarchy of screens).
I assume the best way to do this is to have each screen as completely separate UIViewControllers, correct? I'm just not sure how to orchestrate the navigation/rendering between them.
I'd appreciate whatever best practices you know of. Thanks!
Upvotes: 1
Views: 1114
Reputation: 1251
Well, I was build the app tested yesterday to play different music instrument. I use UIView
to handle view for 3 of my instrument. The logic is simple. I put the navigation on UIButton
and add a subview
for each instrument. When the user touch the button, the selected view will be add to the front, and the last view will be release or temporary on the background.
Hope it will help you.
Upvotes: 0
Reputation: 2169
Well here is a possible option:
First of all if you want a menu outside of these puzzles have that as your root view controller in a UINavigationController
.
Then create a launcher controller and add it to the navigation controller when appropriate. This will be a regular UIViewController
except in this controller in the viewWillAppear
method have it pick a random number 0-5 and run it through a switch and depending on the number push one of your 5 view controllers. Then when the puzzle is completed call popViewController
on the navigation controller. Now when it pops back, viewWillAppear
will be called again and randomly push another. Then if you want to go back to the main menu at any time just call popToRootViewControllerAnimated
. This should do what you need. And to make it so it doesn't animate twice either only have the push animate or only the pop.
Upvotes: 2
Reputation: 830
I know that using cocos2d is a great way to build games and it allows different "scenes" where things are independent of each other or can communicate if you choose. Also with cocos2d there is a "director" that handles all of the scenes and can push scenes for you. If you are curious check out: www.cocos2d-iphone.org
I hope this helps :)
Upvotes: 0
Reputation: 1579
Rather than having different view controllers you can have a single controller. You can reload the view of the puzzle after completing the first. The logic you have applied for the first puzzle will be some what similar to the the others. So now only you need to handle different states of the puzzle. For example: I have first view with puzzle 3x3 matrix, the next will be 4x4 matrix and the next will be 5x5 matrix. So this states needs to be handled through code in view controller.
Upvotes: 0