我有 2 个视图控制器:
- DemoAppViewController
- 关于ViewController
我在 DemoAppViewController 中有一个信息按钮,它应该打开 AboutViewController。
目前我遇到运行时错误,我似乎无法弄清楚为什么..
这是代码:
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];
}
当我使用 xCode 创建 AboutViewController 对象时,initWithNibName
将以下代码添加到 AboutViewController.m:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
我没有动过上面的内容。
运行时错误:
[DemoAppViewController showInfo:]: unrecognized selector sent to instance 0x688e450
有人可以告诉我哪里出错了吗?谢谢。