I have an app that's all in one window and i have different buttons that just load views. I can only make the view go forward or back one at a time, so i need to make some kind of function that i can set so when a button is pressed, it returns to the main screen of the application.
couldn't you iterate through all the views in the navigationController stack, calling pop on each view until the view count is one. Also there is an animated parameter on the pop method, you could set that to no.
couldn't you iterate through all the views in the navigationController stack, calling pop on each view until the view count is one. Also there is an animated parameter on the pop method, you could set that to no.
actually if you look in the header file for UINavigationController you'll see they already have method that does this for you:
Code:
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated; // Pops until there's only a single view controller left on the stack. Returns the popped controllers.
actually if you look in the header file for UINavigationController you'll see they already have method that does this for you:
Code:
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated; // Pops until there's only a single view controller left on the stack. Returns the popped controllers.
Im trying to do this from inside a uiview, no a viewcontroller
how are you loading the views, are you not using a navigation controller?
and how are you handling the button touch action, if not in a view controller?
Here is my project:
You have to play through the game to get to what i am talking about. On the final page, it shows your score and has a home button. I want to make that button go home instead of going back one page like i have it do now.
I just looked through your code, and there is all sorts of programming caveats in there. Good luck getting it to work how you want. Sorry that I can't be of any more help.
I just looked through your code, and there is all sorts of programming caveats in there. Good luck getting it to work how you want. Sorry that I can't be of any more help.
What caveats are you talking about specifically? All i want is for the home button to go back to the menu page.
yea hes right, you really aren't doing things in a very iphoney way... I would really suggest spending some time at apple's dev site reading their documentation: iPhone Dev Center - Apple Developer Connection
As far as your code goes, your really should have a separate view controller for each of your views. The you main view can become your rootView that way you can then use a navigation controller to push views on to the stack and the pop them as you need, and specifically use the function i referenced in one of my past post.
Good luck friend, you'll get there. But you're gonna have to some reading first