I’ve got 2 viewControllers:
- DemoAppViewController
- AboutViewController
I have an info button in DemoAppViewController which is supposed to open AboutViewController.
At the moment I’m getting a run time error and i can’t seem to work out why..
Here’s the code:
DemoAppViewController .h:
- (IBAction)showInfo;
DemoAppViewController.m:
- (IBAction)showInfo {
AboutViewController *controller = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
//setting style with modalTransition property
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
//show on screen
[self presentViewController:controller animated:YES completion:nil];
}
When i create the AboutViewController object with initWithNibName xCode adds the following code to AboutViewController.m:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
I’ve left the above untouched.
Runtime error:
[DemoAppViewController showInfo:]: unrecognized selector sent to instance 0x688e450
Can someone tell me where I’m going wrong?
Thanks.
The selector for this method is
@selector(showInfo), not@selector(showInfo:). If you assign it programmatically, just correct it. If you use IB – add:(id) senderparameter to the method.