2010-12-12 37 views
0

我推test2ViewController在Test1ViewController.m,添加的視圖的按鈕不起作用

Test2ViewController *test2ViewController = [[Test2ViewController alloc] initWithNibName:@"Test2ViewController" bundle:nil]; 
[self.navigationController pushViewController:test2ViewController animated:YES]; 

在Test2ViewController.m,我插入一個子視圖test3ViewController,

Test3ViewController *test3ViewController = [[Test3ViewController alloc] initWithNibName:@"Test3ViewController" bundle:nil]; 
[self.view addSubview:test3ViewController.view]; 

我的問題,我想推test3ViewController中的新視圖(test4ViewController),但test3ViewController.view中的按鈕操作不起作用

-(IBAction) goButtonAction:(id) sender { 
    Test4ViewController *test4ViewController = [[Test4ViewController alloc] initWithNibName:@"Test4ViewController" bundle:nil]; 
    [self.navigationController pushViewController:test4ViewController animated:YES]; 
} 

似乎test3ViewController不在導航流程中,我如何在插入視圖上推新視圖?

回答

0

test3ViewController從未添加到navigationController的堆棧中。如果你想推test4ViewController,那麼你將不得不無論是從test2ViewController做到這一點,或使用setViewControlers:動畫:UINavigationController的方法來test3ViewController添加到堆棧:

NSMutableArray *array = [NSMutableArray arrayWithArray:test2ViewController.navigationController.viewControllers]; 
[array addObject:test3ViewController]; 
[test2ViewController.navigationController setViewControllers:array animated:NO]; 
[test2ViewController.navigationController popToViewController:test3ViewController animated:NO]; 
+0

感謝您的建議。我試過這個。但它仍然不起作用。 – Donny 2010-12-12 21:28:13

+0

你確定IBAction被調用嗎? – Jumhyn 2010-12-12 21:38:28

相關問題