当我按下按钮时,我的应用程序崩溃了。当我在旧项目中使用它时,此代码工作正常。但是当我将它复制到新创建的项目中时,它会崩溃。
这是代码。
-(void)buttonPressed{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - View lifecycle
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
[super loadView];
UIButton *btn=[[[UIButton alloc]initWithFrame:CGRectMake(10, 10, 40, 40)]autorelease];
btn.backgroundColor=[UIColor redColor];
[btn addTarget:self action:@selector(buttonPressed \
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
错误是
2011-12-15 13:22:50.920 TwitterTest[11267:bc03] -[__NSCFArray buttonPressed]:
unrecognized selector sent to instance 0x6042e10
是否有其他人遇到此问题。它只发生在新项目中,而不是现有项目。我正在使用XCode 4.2 build 4D199