Hi everyone, my first question here so be gentle :)
I am trying to use a navigationController to switch views. I got the following down: I got a MainView controller which switches to different view controllers using this code:
UIButton *buttonPressed = (UIButton *)sender;
switch (buttonPressed.tag) {
case 1:
viewController = catalogView;
break;
case 2:
viewController = locatorView;
break;
case 3:
viewController = galleryView;
break;
}
[[self navigationController] pushViewController:viewController animated:YES];
Now I try, to switch to another view in one of these views.
I figured: I have to import the main view and simply create a method here to switch views.
e.g.
- (IBAction)goToProductView {
//UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Test" message:@"hier" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil] autorelease];
//[alert show];
viewController = galleryView;
[[self navigationController] pushViewController:viewController animated:YES];
}
and I call this function from within a viewcontroller like so:
myViewController *mainView = [[myViewController alloc] init];
[[self navigationController] popViewControllerAnimated:NO];
[mainView goToProductView];
The function of mainView gets called here (the alert shows if I unquote it) but the view does not change.
Anyone here can tell me why, or has a better solution?
Thanks in advance
(ps. if I missed any information please feel free to ask and I will supply them asap)