2010-10-07 74 views
0

我有一个MasterViewController.hmxib(UIViewController中)的另一个实例,在下面的方式打开TestDummy.hmxib(UIViewController中):使用的viewController打开相同的viewController

TestDummy *controller = [[TestDummy alloc] initWithNibName:@"TestDummy" bundle:nil]; 
[scrollView addSubview:controller.view]; 

我有两个TestDummy中的按钮:(打开),(关闭)和一个标签:(windowDepth)。

我试图创建第一个TestDummy打开的第二个实例TestDummy。然后允许多个TestDummy(UIViewController)打开到N深度并允许关闭按钮将它们带回零深度。这是我的打开按钮。

-(IBAction) btnOpen_Clicked{ 
TestDummy *newController = [[TestDummy alloc] initWithNibName:@"TestDummy" bundle:nil]; 
newController.isNotRoot = YES; 
newController.windowDepth = self.windowDepth + 1; 
//do stuff... 
childDummy = newController; 

// start the animated transition 
[UIView beginAnimations:@"page transition" context:nil]; 
[UIView setAnimationDuration:1.0]; 
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 

//insert your new subview 
[self.view addSubview:newController.view]; 

// commit the transition animation 
[UIView commitAnimations]; 
[newController release]; 

}

当我这样做,我得到在调试控制台中的错误。

2010-10-07 00:59:12.549 OrionClient[5821:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType btnOpen_Clicked]: unrecognized selector sent to instance 0x6a339a0' 

必须是内存管理问题,但我无法弄清楚。

在此先感谢。

回答

0

'NSInvalidArgumentException' 的,理由是: ' - [__ NSCFType btnOpen_Clicked]: 无法识别的选择发送到实例 0x6a339a0'

这意味着你正在尝试调用该实例上不存在的方法。你是如何定义btnOpen_Clicked选择器的?我猜它应该看起来更像,但真的需要看看你如何定义选择器。

-(IBAction) btnOpen_Clicked:(id)sender 
0

这意味着应用程序无法找到您的方法btnOpen_Clicked

先用重命名你的方法:

-(IBAction) btnOpen_Clicked:(id)sender 

并确保此方法规范在.h文件 而在InterfaceBuilder中有你的TestDummy.xib,同时也要确保该按钮,这之间的联系方法已正确完成,例如TouchUpInside事件。

0

解决了它删除了最后一行[newController release];需要弄清楚在哪里实际调用它,但是。

相关问题