添加视图按钮不起作用
我在 Test1ViewController.m 中推送 test2ViewController,
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不在导航流程中,如何在插入视图上推送新视图?
I push test2ViewController in Test1ViewController.m,
Test2ViewController *test2ViewController = [[Test2ViewController alloc] initWithNibName:@"Test2ViewController" bundle:nil];
[self.navigationController pushViewController:test2ViewController animated:YES];
in Test2ViewController.m, I insert a subview test3ViewController,
Test3ViewController *test3ViewController = [[Test3ViewController alloc] initWithNibName:@"Test3ViewController" bundle:nil];
[self.view addSubview:test3ViewController.view];
my question, I wanna push a new view (test4ViewController) in test3ViewController, but the button action in test3ViewController.view does not work
-(IBAction) goButtonAction:(id) sender {
Test4ViewController *test4ViewController = [[Test4ViewController alloc] initWithNibName:@"Test4ViewController" bundle:nil];
[self.navigationController pushViewController:test4ViewController animated:YES];
}
It seem that the test3ViewController is not in navigation flow, how can I push a new view on a insert view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
test3ViewController 从未添加到 navigationController 的堆栈中。如果您想推送 test4ViewController,那么您必须从 test2ViewController 执行此操作,或者使用 UINavigationController 的 setViewControlers:animated: 方法将 test3ViewController 添加到堆栈中:
test3ViewController was never added to the stack for the navigationController. If you want to push test4ViewController, then you will have to either do it from test2ViewController, or use the setViewControlers:animated: method of UINavigationController to add test3ViewController to the stack: