开发者

Push Viewcontroller from within other ViewControllers that are not on top of Navstack?

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 ont开发者_Python百科o 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!


You're allocating a new MainViewController and sending your -loadMapView message to that, rather than any existing MainViewController in the navigation stack. Hence, [self navigationController] in that method is nil and the -pushViewController:animated: method is a no-op.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜