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 Tutorials > Tutorial Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 05-20-2009, 08:47 PM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 15
Smile EASY TUTORIAL ON SWITCHING VIEWS

I have somewhere along the way made a mistake and do not have time to fix it. Can someone please post the source code for this tutorial?? It would be extremely helpful.
GeoffMilburn is offline   Reply With Quote
Old 12-14-2009, 09:36 AM   #2 (permalink)
Persian Developer
 
Join Date: Mar 2009
Posts: 274
Default

Quote:
Originally Posted by GeoffMilburn View Post
I have somewhere along the way made a mistake and do not have time to fix it. Can someone please post the source code for this tutorial?? It would be extremely helpful.
it's very simple first of all add a UIViewController [check the xib too ] to your project and . let's write the code

Assuming i have a button on the FirstViewController , ok ,

FirstViewController.h :

Code:
-(IBAction)gotoViewTwo:(id)sender ;

FirstViewController.m :

#import "FirstViewController.h"
#import "SecondViewController.h"


Code:
-(IBAction)gotoViewOne:(id)sender 

{

SocondViewController *viewTwo= [[SecondViewController alloc] initWithNibName:@"SocondViewController " bundle:nil];
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:1];
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
	[self.view addSubview:viewTwo.view];
	[UIView commitAnimations];

}
write above codes for button on the view 2 :



Code:
#import "SecondViewController.h"
#import "FirstViewController.h"


FirstViewController *viewOne= [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:1];
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
	[self.view addSubview:viewOne.view];
	[UIView commitAnimations];

}
__________________
My Applications On the App Store


Momeks is offline   Reply With Quote
Old 05-20-2010, 02:13 AM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 2
Default

This code only works on touch inside, and not touch drag inside... any ideas why not???

Nino



Quote:
Originally Posted by Momeks View Post
it's very simple first of all add a UIViewController [check the xib too ] to your project and . let's write the code

Assuming i have a button on the FirstViewController , ok ,

FirstViewController.h :

Code:
-(IBAction)gotoViewTwo:(id)sender ;

FirstViewController.m :

#import "FirstViewController.h"
#import "SecondViewController.h"


Code:
-(IBAction)gotoViewOne:(id)sender 

{

SocondViewController *viewTwo= [[SecondViewController alloc] initWithNibName:@"SocondViewController " bundle:nil];
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:1];
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
	[self.view addSubview:viewTwo.view];
	[UIView commitAnimations];

}
write above codes for button on the view 2 :



Code:
#import "SecondViewController.h"
#import "FirstViewController.h"


FirstViewController *viewOne= [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:1];
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
	[self.view addSubview:viewOne.view];
	[UIView commitAnimations];

}
nino90 is offline   Reply With Quote
Old 05-20-2010, 11:43 AM   #4 (permalink)
Beast Iphone Developor
 
justill45's Avatar
 
Join Date: Aug 2009
Location: Atlanta, Georgia
Age: 16
Posts: 1,302
Default

Quote:
Originally Posted by nino90 View Post
This code only works on touch inside, and not touch drag inside... any ideas why not???

Nino
the code is in the form of an action so it will work on any type.
justill45 is offline   Reply With Quote
Old 05-20-2010, 05:36 PM   #5 (permalink)
Beast Iphone Developor
 
justill45's Avatar
 
Join Date: Aug 2009
Location: Atlanta, Georgia
Age: 16
Posts: 1,302
Default

Quote:
Originally Posted by Momeks View Post
it's very simple first of all add a UIViewController [check the xib too ] to your project and . let's write the code

Assuming i have a button on the FirstViewController , ok ,

FirstViewController.h :

Code:
-(IBAction)gotoViewTwo:(id)sender ;

FirstViewController.m :

#import "FirstViewController.h"
#import "SecondViewController.h"


Code:
-(IBAction)gotoViewOne:(id)sender 

{

SocondViewController *viewTwo= [[SecondViewController alloc] initWithNibName:@"SocondViewController " bundle:nil];
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:1];
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
	[self.view addSubview:viewTwo.view];
	[UIView commitAnimations];

}
write above codes for button on the view 2 :



Code:
#import "SecondViewController.h"
#import "FirstViewController.h"


FirstViewController *viewOne= [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:1];
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
	[self.view addSubview:viewOne.view];
	[UIView commitAnimations];

}


if u keep adding each one to self.view as a subview, wont it stack up because your not getting rid of the view, just covering it with another view, or does it get rid of the view underneath?
justill45 is offline   Reply With Quote
Old 07-25-2010, 05:02 AM   #6 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 1
Default

Quote:
Originally Posted by justill45 View Post
if u keep adding each one to self.view as a subview, wont it stack up because your not getting rid of the view, just covering it with another view, or does it get rid of the view underneath?
U could use the UINavigationController, it makes switching views easier and you always have a back button to return to the last view.

i think it's cooler than switching views manually
nightfall91 is offline   Reply With Quote
Reply

Bookmarks

Tags
switching, tutorial, views

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: 254
15 members and 239 guests
@sandris, ADY, Alsahir, dacapo, Dani77, Desert Diva, djohnson, HemiMG, jansan, M@realobjects, MarkC, prchn4christ, smethorst, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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