views:

89

answers:

1

Hi,

Pardon the simple question, but I am pulling my hair out trying to get a grip around navigation in the iPhone.

So, I have a Tab Bar Controller type application with UITabBar and 3 UITabBarItems. I have the 1st Tab Bar Item loading a kind of "Home Screen/Welcome", on the Home Screen, there is a button. When the user clicks the button, I want to open a different UIViewController (LoginViewViewController) to allow the person to login.

I am trying to basically, switch UIViewController and then when they have successfully logged in, I want to change the TabBarItems.

This is the code that I have in the .m file on the ViewController that is connected to the 1st TabBarItem:

#import "LaunchViewViewController.h"
#import "LoginViewViewController.h"

@implementation LaunchViewViewController

@synthesize myLoginViewViewController;

- (IBAction)cmdRSVP_Click:(id)sender {

 //Try #1
 //[self addSubview:myLoginViewViewController.view];

 //Try #2
 //[[self navigationController] pushViewController:myLoginViewViewController animated:YES];

 //Try #3
 //LoginViewViewController *myLoginViewViewController2 = [[LoginViewViewController alloc] initWithNibName:@"LoginView" bundle:[NSBundle mainBundle]];
 //[self.navigationController pushViewController:myLoginViewViewController2 animated:YES];
 //[myLoginViewViewController2 release];
 //myLoginViewViewController2 = nil;

 //Try #4
 //This just changes my screen to all White (expect the TabBarNavigationController
 //[self.view removeFromSuperview];
 //[self.view insertSubview:self.myLoginViewViewController.view atIndex:0];


 // This displays without issue.
 [self displayMessage:@"RSVP Clicked":@"Switch to Login View"]; }

As, you can see, I have tried 4 different ways that I have seen in various tutorials.

In try 1, 2, 3: Nothing happens (no crash or exception), but the Alert Message box is still displayed.

In try 4, the screen area above the Tab Bar Controller changes to White and the Alert Message is displayed, but it never shows my other ViewController.

Any help getting me on track would be great!!!

Thanks in advance! Jason

A: 

Hi,

I was able to figure this out based on another question that I asked.

The issue was that I needed to have a UINavigation controller connected to the Tab Bar Item (not a UIViewController). The UIViewController would then be the RootViewController of the UINavigation controller, which would then allow me to use the pushViewController and popViewController methods.

NOTE: This is the link to the question that helped me resolve this question: http://stackoverflow.com/questions/3464889/tableview-does-not-switch-to-detail-view-when-connected-to-tab-bar-controller

Jason

JasonBub
this is really the link that got me to understand what was going on: http://stackoverflow.com/questions/284321/hidden-uinavigationcontroller-inside-uitabbarcontroller
JasonBub