Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-23-2009, 08:56 PM   #1 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 532
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Exclamation Application "Home" button

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.

Thanks,
Chase.
chaseacton is offline   Reply With Quote
Old 06-23-2009, 10:05 PM   #2 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 532
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default

Anyone?
chaseacton is offline   Reply With Quote
Old 06-23-2009, 10:29 PM   #3 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 18
Default

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.
wolof is offline   Reply With Quote
Old 06-23-2009, 10:30 PM   #4 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 532
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default

Quote:
Originally Posted by wolof View Post
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.
Thanks for the reply, but how would i do this?
chaseacton is offline   Reply With Quote
Old 06-23-2009, 10:48 PM   #5 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 18
Default

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.
wolof is offline   Reply With Quote
Old 06-23-2009, 10:55 PM   #6 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 532
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default

Quote:
Originally Posted by wolof View Post
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
chaseacton is offline   Reply With Quote
Old 06-23-2009, 10:59 PM   #7 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 18
Default

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?
wolof is offline   Reply With Quote
Old 06-23-2009, 11:20 PM   #8 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 532
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default

Quote:
Originally Posted by wolof View Post
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.

help.zip

Thank you SOO much

Chase.
chaseacton is offline   Reply With Quote
Old 06-23-2009, 11:30 PM   #9 (permalink)
1026 Development
 
Join Date: Jul 2008
Age: 23
Posts: 1,088
Send a message via AIM to Jeremy1026
Default

Hey Chase,

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.
Jeremy1026 is offline   Reply With Quote
Old 06-23-2009, 11:34 PM   #10 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 532
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default

Quote:
Originally Posted by Jeremy1026 View Post
Hey Chase,

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.
chaseacton is offline   Reply With Quote
Old 06-23-2009, 11:45 PM   #11 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 18
Default

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

if you don't mind spending the money, i'd really suggest picking up this book, it really helped me out alot: APRESS.COM : Beginning iPhone Development: Exploring the iPhone SDK : 9781430216261

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
wolof is offline   Reply With Quote
Reply

Bookmarks

Tags
button, code, home, tutorial

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 261
20 members and 241 guests
2WeeksToGo, ADY, BrianSlick, dacapo, Dani77, Dattee, Duncan C, headkaze, IphoneSdk, jemicha, kapps11, mer10, mgon987, Punkjumper, sneaky, timle8n1
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,879
Threads: 89,228
Posts: 380,743
Top Poster: BrianSlick (7,129)
Welcome to our newest member, mgon987
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:41 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0