视图控制器没有被推入堆栈
我对 iPhone 相当陌生。我有一个特殊的问题。我将视图控制器作为子视图添加到当前视图。然后我想从中推送一个新的视图控制器。问题是当我尝试执行pushViewController 时,它没有响应。
例如,在 CurrentViewController 中,我已将 NewViewController 的视图添加为
[self.view addSubView : NewViewController.view]
现在来自 NewViewController 的子视图,单击按钮我将执行以下操作:
SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondVC animated:YES];
这里,第二个 VC 不会被推送到堆栈。
I am fairly new to iPhone. I have a peculiar problem. I am adding a view controller as a subView to the current view. And then I want to push a new view controller from it. The problem is when I try to do pushViewController, it is not responding.
For example, in CurrentViewController I have added NewViewController's view as subView
[self.view addSubView : NewViewController.view]
Now From NewViewController, on the click of a button I am doing the following :
SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondVC animated:YES];
Here the secondVC doesn't get pushed to the stack.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用过基于视图的应用程序,则必须使用此代码。
如果你想在你的应用程序中使用导航控制器。首先,您必须在应用程序中添加导航控制器,然后才可以导航视图。
If you have used view based application, You have to use this code.
If you want to use navigation controller in your appln. First you have to add navigation controller in your appln and then only will navigate the view.
也许问题在于该方法被称为
pushViewController
而不是pushToViewController
。尝试Perhaps the problem is that method is called
pushViewController
notpushToViewController
. Try