子视图控制器通知根视图控制器加载另一个子视图控制器

时间:2010-01-31 08:32:12

标签: iphone

我有一个项目,其中根视图控制器调用多个viewcontrollers。子视图控制器的视图上有按钮,当我按下按钮时,我希望它通知根视图控制器加载另一个子视图控制器。

//the function in this viewcontroller

-(IBAction)submitButtonPressed:(id)sender;
{
     [self.parentViewController   notifyLoadAnotherViewContrller ] ; 

}   


//the function in root viewcontroller
-(void) notifyLoadAnotherViewContrller 
{

    Submit *tController = [[AnotherViewController alloc] initWithNibName: @"AnotherViewController" bundle:nil];
    self.vanotherViewController = tController;

    [tController release];


    [self.view insertSubview:tController.view atIndex:10];



}

但这不起作用 我在函数中设置了断点 - (void)notifyLoadAnotherViewContrller

它不起作用我检查了函数名称,没问题。

我做错了什么原因?

欢迎任何评论

最好的问候

InterDev中

1 个答案:

答案 0 :(得分:0)

所以一些标准调试...在submitButtonPressed中设置一个断点:确保你的IBAction正确连接。检查parentViewController以确保它符合您的期望。

由于该方法未被调用,因此您的按钮未在Interface Builder中连接,或者您的parentViewController为nil,这将无声地忽略方法调用。

相关问题