从不在 Navstack 之上的其他 ViewController 中推送 Viewcontroller?
我有一个滚动视图加载到我的主视图中(带有页面控制)。我想做的是让滚动视图使用“Touchesbegan”方法来查找双击,然后将新的视图控制器推送到导航堆栈上。第二个目标似乎不可能实现。
我让单独的滚动视图控制器调用主视图控制器中的方法。该方法应该将一个新的视图控制器推送到堆栈上。它没有,但是当我从 mainviewcontroller 类中调用这个方法时,它确实有效吗?!
在scrollviewcontroller类中:
MainViewController *mvcC = [[MainViewController alloc] init];
[mvcC loadMapView];
[mvcC release];
在mainviewcontroller类中:
-(void) loadMapView {
[[self navigationController] pushViewController:mapViewController animated:YES];
NSLog(@"loadMapView method is called!");
}
谢谢!
i have a scrollview loaded into my mainview (with pagecontrol). What i want to do is to have the scrollview use the "Touchesbegan" method to look for double taps and then have it push a new viewcontroller onto the navstack. The second goal seems impossible.
I have the seperated scrollviewcontroller call a method in the mainviewcontroller. That method should push a new viewcontroller onto the stack. It doesnt, but when i call this method from within the mainviewcontrollerclass it does work?!
in the scrollviewcontroller class:
MainViewController *mvcC = [[MainViewController alloc] init];
[mvcC loadMapView];
[mvcC release];
in the mainviewcontroller class:
-(void) loadMapView {
[[self navigationController] pushViewController:mapViewController animated:YES];
NSLog(@"loadMapView method is called!");
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将分配一个新的
MainViewController
并向其发送-loadMapView
消息,而不是导航堆栈中任何现有的MainViewController
消息。因此,该方法中的[self navigationController]
为 nil,而-pushViewController:animated:
方法是无操作。You're allocating a new
MainViewController
and sending your-loadMapView
message to that, rather than any existingMainViewController
in the navigation stack. Hence,[self navigationController]
in that method is nil and the-pushViewController:animated:
method is a no-op.