Hi, i am going to teach you how to switch view controllers.
First Goto file New Project, and name it SwitchViews.
Secondly you need to program an IBAction in your .H file. It needs to look something like this:
Code:
- (IBAction)switchViews;
Once you have done that open Interface Builder and create a new Round Rect Button. Then hold down ctrl from the files owner to the button. Then a small menu should popup. Select switchViews, and touch up inside.
Next right click on the classes folder and add a new View Controller Subclass, and name it SecondView. Make sure you select it to come with a XIB interface.
Now go into the SwitchViewsViewController.M file.
First Import the viewController that you want to switch to. This goes above the @implementation SecondView
Code:
#import "SecondView.h"
We now need to program the button.
Code:
- (IBAction)switchViews
//Change secondView and replace it with you viewcontroller that you want to switch to.
{
SecondView *second = [[[SecondView alloc] initWithNibName:@"SecondView" bundle:nil] autorelease];
// you can change flip horizontal to many different other transition styles.
second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:second animated:YES];
}
Now we need to make a back button in the SecondView to let us go back to the original view.
So open up SecondView.h and make an IBAction called goBack.
Code:
- (IBAction)goBack;
Open up SecondView.m and we will program it. So open your .M file:
Code:
- (IBAction)goBack
{
[self dismissModalViewControllerAnimated:YES];
}
Finally open Interface Builder with the SecondView.xib
Add a Navigation Bar and a ToolBar Button.
Rename the ToolBar Button to Back and the click on Files Owner and drag the IBAction to the Back button, and select goBack.
Now that should work, Hope this Helps.