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.
精彩评论