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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 08-18-2011, 12:43 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 17
appcody is on a distinguished road
Post Switching Views

Hi,

I have been making buttons and making them take you to a different view once their tapped. I am currently using IBActions and defining them as View1 setHidden: Yes and View2 setHidden No, which just causes the other view to appear. This gets really tiring though when you need a different view to disappear (what I'm trying to say you can't just simply copy and paste). Is there a way of linking the buttons together into one code, like for example say that I have 50 different views, and all of them have one button for the main menu. I would have to make 50 IBActions, but I am looking for a way to say something like 'take user to "MainView" '. You would probably have to do it with an 'if', but I have no idea how to start this problem at all.

Thanks in advance,
appcody is offline   Reply With Quote
Old 08-18-2011, 12:47 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Quote:
Originally Posted by appcody View Post
Hi,

I have been making buttons and making them take you to a different view once their tapped. I am currently using IBActions and defining them as View1 setHidden: Yes and View2 setHidden No, which just causes the other view to appear. This gets really tiring though when you need a different view to disappear (what I'm trying to say you can't just simply copy and paste). Is there a way of linking the buttons together into one code, like for example say that I have 50 different views, and all of them have one button for the main menu. I would have to make 50 IBActions, but I am looking for a way to say something like 'take user to "MainView" '. You would probably have to do it with an 'if', but I have no idea how to start this problem at all.

Thanks in advance,
I think you need to brush up on what View Controllers are for and how you switch between views. It sounds like you've got all views active at once and you hide the ones you don't want to see? That is completely the wrong approach.

Read this: iPhone Programming Tutorial ? Transitioning Between Views | iPhone Programming Tutorials
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Old 08-18-2011, 12:55 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 17
appcody is on a distinguished road
Post

Quote:
Originally Posted by MattW View Post
I think you need to brush up on what View Controllers are for and how you switch between views. It sounds like you've got all views active at once and you hide the ones you don't want to see? That is completely the wrong approach.

Read this: iPhone Programming Tutorial ? Transitioning Between Views | iPhone Programming Tutorials

Hi,

Thanks for your reply. I know how to use the navigation controllers and view controllers though. So should I just make a view, link it to a view controller, but instead of the 'didselectrowatindexpath' should I say something like 'didselectbutton'? I would have to switch everything to something else. And its more of a game, so I can't really use the navigation controller with table cells.
appcody is offline   Reply With Quote
Old 08-19-2011, 03:24 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 17
appcody is on a distinguished road
Question Bumping my thread

Hi,

I am bumping my thread so it gets noticed again, because right now its on page 3, and is not likely to get any more attention.

I have tried to solve my problem (the one stated at the very top), but I couldn't figure it out yet. I tried implementing the ModalView, but I don't want it to be a ModalView, because I need it to be another 'main' screen.
appcody is offline   Reply With Quote
Old 08-22-2011, 07:52 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 17
appcody is on a distinguished road
Question Still have problems

Hi,

does anybody know how to solve my problem? I'm still stuck on it.

Thanks,
appcody is offline   Reply With Quote
Old 08-22-2011, 08:13 AM   #6 (permalink)
Registered Member
 
Join Date: Aug 2010
Location: Edinburgh
Posts: 209
Justinmichael is on a distinguished road
Default

Quote:
Originally Posted by appcody View Post
Hi,

does anybody know how to solve my problem? I'm still stuck on it.

Thanks,
Yeah, say you have 2 screens (saying screen not to confuse with UIView). Screen 1 = menu, Screen 2 = game.

Screen 1 and 2 (GameScreen) would extend UIViewController. When someone hits your button you call your IBAction and present the view modally. You can change the animation for entry but I'll leave you to look at the docs for that (or you can set to NO to make it instantly show):

Code:
- (IBAction)didHitPlay {
    GameScreen* gameScreen = [[GameScreen alloc] init];
    [self presentModelViewController:gameScreen animated:NO];
    [gameScreen release];
}
__________________
Justinmichael is offline   Reply With Quote
Old 08-22-2011, 08:57 AM   #7 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 9
penpaper is on a distinguished road
Post

Quote:
Originally Posted by Justinmichael View Post
Yeah, say you have 2 screens (saying screen not to confuse with UIView). Screen 1 = menu, Screen 2 = game.

Screen 1 and 2 (GameScreen) would extend UIViewController. When someone hits your button you call your IBAction and present the view modally. You can change the animation for entry but I'll leave you to look at the docs for that (or you can set to NO to make it instantly show):

Code:
- (IBAction)didHitPlay {
    GameScreen* gameScreen = [[GameScreen alloc] init];
    [self presentModelViewController:gameScreen animated:NO];
    [gameScreen release];
}
Thanks for your reply. I tried implementing that, and I got everything to work, except that when I build and run I get an error that I need to declare the 'GameScreen'. I made an xib with the name of GameScreen though. And the window is linked to the GameScreenViewController. Any ideas?

Thanks
penpaper is offline   Reply With Quote
Old 08-22-2011, 09:08 AM   #8 (permalink)
Registered Member
 
Join Date: Aug 2010
Location: Edinburgh
Posts: 209
Justinmichael is on a distinguished road
Default

Quote:
Originally Posted by penpaper View Post
Thanks for your reply. I tried implementing that, and I got everything to work, except that when I build and run I get an error that I need to declare the 'GameScreen'. I made an xib with the name of GameScreen though. And the window is linked to the GameScreenViewController. Any ideas?

Thanks
Yeah, I made GameScreen up. I should have been clearer, you need to replace this with the classname of your second UIViewController (which you can add a nib for when you create if you like).
__________________
Justinmichael is offline   Reply With Quote
Reply

Bookmarks

Tags
button, hidden, ibaction, switch, view

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: 390
14 members and 376 guests
7twenty7, chiataytuday, cristofercolmbos, dedeys78, fiftysixty, gmarro, iOS.Lover, jimmyon122, jonathandeknudt, pungs, raymng, stanny, tymex, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

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