我用单击按钮时触发的IBAction成功加载了新的视图控制器。我怎么不能解雇我加载的视图控制器?
-(IBAction)changeToAnotherView:(id)sender
{
if (self.newController == nil)
{
newController = [[UIViewController alloc] initWithNibName:@"NewViewController" bundle:[NSBundle mainBundle]];
}
quizController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:newController animated:YES completion:NULL];
}
但是,我的函数返回到NewViewController.m中的旧视图不构建。为什么?
- (IBAction)goBackToOldView:(id)sender
{
[self dismissWithClickedButtonIndex:0 animated:YES];
}
我得到的构建错误是“No visible interface declares dismissWithClickedButtonIndex:animated:”。
更新:
LLDB现在输出
"2012-04-30 21:31:56.530 Project32[10105:fb03] -[UIViewController goBackToOldView:]: unrecognized selector sent to instance 0x6c57f20
2012-04-30 21:31:56.531 Project32[10105:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController goBackToOldView:]: unrecognized selector sent to instance 0x6c57f20'
*** First throw call stack:
(0x1649052 0x1bfdd0a 0x164aced 0x15aff00 0x15afce2 0x164aec9 0x2d05c2 0x50bd54 0x164aec9 0x2d05c2 0x2d055a 0x375b76 0x37603f 0x3752fe 0x2f5a30 0x2f5c56 0x2dc384 0x2cfaa9 0x2536fa9 0x161d1c5 0x1582022 0x158090a 0x157fdb4 0x157fccb 0x2535879 0x253593e 0x2cda9b 0x217d 0x20e5)
terminate called throwing an exception(lldb)"
有趣的是,我在NewViewController实现goBackToOldView
:
- (IBAction)goBackToOldView:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
}
检查,如果你确实有它在正确的地方,发表意见自dismissmodal部分.. ,并把一个NSLog(@“按钮推”);它可能会给你同样的错误,这意味着你按下的按钮可能没有连接到正确的操作,在界面生成器中探索它,检查器的最后一个选项卡显示它的连接。确保它指向具有newviewcontroler.m的控制器实施 – Pochi
谢谢,你是对的!评论解雇......并用NSLog替换它(@“回去!”);'同样失败。这真的很奇怪。我只是从我的Nib文件拖动了该行并选择了goBack。奇怪... –
嗯,你有什么调试建议吗?检查员的最后一个标签显示了我相信的正确功能。 –