Hi, I'm a newbie to iPhone coding and am having problems with the UINavigation control.
I have 3 views (main menu, news and login). The main menu is my base view in the root controller and then I push the login or news views onto the stack when the user clicks the button from the main menu. However, if I am on the news screen and want to switch to the login view, I would expect to pop the current view (takes me back to the main menu), and push the login view. However, this does not happen and I'm not sure why...
Here is the code from my AppDelegate:
@synthesize window;
@synthesize rootController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
[window addSubview:rootController.view];
[window makeKeyAndVisible];
}
- (IBAction)loadLoginView
{
[self loadMainMenuView];
LoginViewController *loginView = [[LoginViewController alloc] initWithNibName:@"LoginView" bundle:nil];
[rootController pushViewController:loginView animated:YES];
[loginView release];
}
- (IBAction)loadNewsView
{
[self loadMainMenuView];
NewsViewController *newsView = [[NewsViewController alloc] initWithNibName:@"NewsView" bundle:nil];
[rootController pushViewController:newsView animated:YES];
[newsView release];
}
- (IBAction)loadMainMenuView
{
[rootController popToRootViewControllerAnimated:YES];
}
- (void)dealloc {
[window release];
[rootController release];
[super dealloc];
}
Can anyone see what I'm doing wrong? Is there a better way to manage this? Thanks!