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 03-26-2009, 09:57 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 13
kingliu is on a distinguished road
Default How switch view using a button?

hi everyone.

I am a new developer.
i am busy to build my first app for iphone.now i don't know how to switch view when i tap a button ? any one can help me ?

Post some code.
kingliu is offline   Reply With Quote
Old 03-26-2009, 10:02 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 17
dearestpankaj is on a distinguished road
Default

Quote:
Originally Posted by kingliu View Post
hi everyone.

I am a new developer.
i am busy to build my first app for iphone.now i don't know how to switch view when i tap a button ? any one can help me ?

Post some code.
Hi,

You can create both views and add them to the current view. Just make them hidden and when you tab on your button make them hidden true or false.

e.g, view.hidden = FALSE;
dearestpankaj is offline   Reply With Quote
Old 03-26-2009, 10:02 PM   #3 (permalink)
Gold Orange
 
orange gold's Avatar
 
Join Date: Sep 2008
Posts: 686
orange gold is an unknown quantity at this point
Default

i suggest you watch the tutorial on switching views...

tut link: http://www.iphonedevcentral.org/tuto...52&uid=3906457

here is the code i would use for a button

Code:
#import "MyView2.h";

@ implementation blah blah blah

-(IBAction) button {
    [self addSubView:myView2];
}

@end
orange gold is offline   Reply With Quote
Old 03-26-2009, 10:11 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 13
kingliu is on a distinguished road
Default

Quote:
Originally Posted by dearestpankaj View Post
Hi,

You can create both views and add them to the current view. Just make them hidden and when you tab on your button make them hidden true or false.

e.g, view.hidden = FALSE;
I have many views ,and i need switch between them frequently. I don't know whether this way costs too much memory .
kingliu is offline   Reply With Quote
Old 03-26-2009, 10:24 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 89
objective-d is on a distinguished road
Default

Quote:
Originally Posted by kingliu View Post
I have many views ,and i need switch between them frequently. I don't know whether this way costs too much memory .
Apple has extensive sample code available at Apple Developer Connection - I'd suggest you look there.

d.
objective-d is offline   Reply With Quote
Old 03-26-2009, 10:30 PM   #6 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 13
kingliu is on a distinguished road
Default

Quote:
Originally Posted by orange gold View Post
i suggest you watch the tutorial on switching views...

tut link: Welcome to the iPhone Development Central Website!

here is the code i would use for a button

Code:
#import "MyView2.h";

@ implementation blah blah blah

-(IBAction) button {
    [self addSubView:myView2];
}

@end

I will try it.Thx
kingliu is offline   Reply With Quote
Old 03-26-2009, 10:37 PM   #7 (permalink)
Gold Orange
 
orange gold's Avatar
 
Join Date: Sep 2008
Posts: 686
orange gold is an unknown quantity at this point
Default

here i made an example of switching between 2 views with buttons and excelent memory storage...

download it here
views.zip
orange gold is offline   Reply With Quote
Old 03-26-2009, 10:44 PM   #8 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 13
kingliu is on a distinguished road
Default

Quote:
Originally Posted by orange gold View Post
here i made an example of switching between 2 views with buttons and excelent memory storage...

download it here
views.zip
Thank you for you reply. I am chinese man. I can't downlod the file. maybe it is the network problem.

Could you send it to my E-mail kingliuice@gmail.com

Thanks!
kingliu is offline   Reply With Quote
Old 04-01-2009, 04:08 PM   #9 (permalink)
Registered Member
 
blackyE's Avatar
 
Join Date: Aug 2008
Location: Germany
Posts: 78
blackyE is on a distinguished road
Default

Quote:
Originally Posted by orange gold View Post
here i made an example of switching between 2 views with buttons and excelent memory storage...

download it here
views.zip

can you plz send it to my email
christopher.sachse@yahoo.de

thx!
blackyE is offline   Reply With Quote
Old 09-20-2010, 09:10 PM   #10 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 129
uvidownloader is on a distinguished road
Default

Zip file never loads can someone PM me a working one ? or e-mail uvidownloader@gmail.com.
uvidownloader is offline   Reply With Quote
Old 04-22-2012, 02:59 PM   #11 (permalink)
Registered Member
 
Join Date: Feb 2012
Posts: 33
iCLSn0w is on a distinguished road
Default

Hello,
1.Create another class, with xib file for example :secondViewController
You can use that :
Code:
- (IBAction)switch {
secondViewController *controller = [[[secondViewController alloc] initWithNibName:@"secondViewController"] autorelease];
[self presentModalViewController:controller animated:NO];
}
You create an animation
Code:
- (IBAction)switch {
secondViewController *controller = [[[secondViewController alloc] initWithNibName:@"secondViewController"] autorelease];
controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:controller animated:YES];
}
iCLSn0w is offline   Reply With Quote
Reply

Bookmarks

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: 332
4 members and 328 guests
blueorb, guusleijsten, Kryckter, LEARN2MAKE
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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