(I’ve just learn objective-c for a short time. I still don’t know how to generate UI elements through writting code now.)
There is one button in .xib.
There is one method in .m.
I want to link these two things by ctrl-click “Touch up Inside” and “File’s owner”. However, no method shows up when I move the mouse cursor onto File’s Owner’s icon.
The situation is like this:
http://www.badongo.com/pic/13577347
the .h file:
#import <UIKit/UIKit.h>
@interface ChangeViewController : UIViewController
{
}
-(IBAction)goToSecondView:(id)sender;
-(IBAction)goToCalculatorView:(id)sender;
-(IBAction)test:(id)sender;
@end
the .m file:
#import "ChangeViewController.h"
#import "SecondViewController.h"
#import "CalculatorViewController.h"
@implementation ChangeViewController
-(IBAction)goToSecondView:(id)sender
{
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondViewController animated:YES];
[secondViewController release];
}
-(IBAction)goToCalculatorView:(id)sender
{
CalculatorViewController *calculatorViewController =[[CalculatorViewController alloc] initWithNibName:@"CalculatorViewController" bundle:nil];
[self.navigationController pushViewController:calculatorViewController animated:YES];
[calculatorViewController release];
}
Is there anything wrong? Thanks.
Also make sure your File’s Owner class is of type ‘
ChangeViewController‘. For doing so, select the File’s Owner, Go to the inspector (press command + 4), and set its class to ‘ChangeViewController‘ if not already set.