Eagle101:
I'm not at my Mac right now so I can't look at your files - but I will explain things a little bit more below.
The -(IBAction)infoButtonWasPressed code is a method. These are analogous to procedures and functions. i.e. it is a block of code that will be executed whenever that method is called.
You need to insert the following code into FirstViewController.m. Put it anywhere after the @implementation where all the other methods are. The -(void)dealloc and -(void)viewDidLoad blocks are all methods so make sure you don't insert it in the middle of these. Each method code block sits between the two sets of {} brackets:
Code:
- (IBAction)infoButtonWasPressed:(id)sender {
// Display modal info view as flipside view
FlipsideViewController *fvc = [[FlipsideViewController alloc] initWithNibName:@"blah blah"];
fvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:fvc animated:YES];
[fvc release];
}
Now let's go through the above code. The -(IBAction) part of the method tells Xcode that the method should be seen by Interface Builder and as the name implies it is an Interface Builder 'action' (hence IBAction). The name of the method is infoButtonWasPressed and it takes one parameter: sender (of type object id). Now you don't strictly need the : (id)sender parameter but it gives us the option of finding out which button was pressed if we so wish - so it passes our method some extra info if we might need it (in this case we don't).
Now the code that runs in that method is enclosed in the {} brackets, with the final } closing off the method. That means that when this method is called, the code inbetween the brackets will be run.
Now let's see what that does. Firstly, we initialise our flipside view controller object (the one you created as a view controller file). We call our instance of that class by an alias name - fvc. The * before it tells Xcode we are dealing with a pointer to that object. Now, we can refer to that particular object by that name anywhere in this method only. Note the init statement also tells it to load your nib file for the flipside view controller (the nib is the Interface Builder file). Next, we set the flipside view controller's modalTransitionStyle property so that it flips into view rather than the default slide in from the bottom. Then the next line actually tells the current view controller to present this view (as a modal view) with animation. The self in this case refers to the current view controller object. Finally, for good memory management, and so we don't leak memory, we have to release the fvc object. We do this because we sent it an init/alloc statement. There's a good Apple guide on memory management if you don't understand this.
Now, before we can use the method, we also need to declare it in the header file - i.e. FirstViewController.h. After the {} and before the @end, you need to insert the following line of code:
Code:
-(IBAction)infoButtonWasPressed:(id)sender;
Note that the line exactly mirrors the name of the method in the .m implementation file (but without the {} brackets). It is a line of code so we need to put the ; at the end to signify it is the end of the line.
You should save both files and then it should show up in Interface Builder in the FirstViewController.xib nib. This is the nib where you should put your info button. When you control drag from the button to the File Owner, the infoButtonWasPressed button pop-up should show up so that you can connect it.
What this does is a shortcut for you that tells Xcode to run your method whenver that button is pressed. Now it should work.