Hi,
I'm new to the iPhone programming world and I have an app that I've been trying to get to work for a week with no success. I wish I could be articulate and ask my question without including code, but I can't do it. (I also hate looking at other people's code in threads...).
I'm trying to build an app that includes a UITabBarController and a UINavigationController. I have seen examples on how to get this working in Interface Builder, but I want to do it programatically. I have created a Tab Bar Application and in MainWindow.xib I correctly hooked up 5 View Controllers.
In my ClientAppDelegate.h file, I have:
The problem is that when I click the second tab (WizardView), it doesn't load the WizardNavigationController which I clearly add it as a subview to WizardView. It does display a half-drawn NavigationController in the view, but I don't think that is the WizardNavigationController. And I don't think I'm loading the NavigationController correctly in the ClientAppDelegate and hooking it up properly in WizardView.xib. Because I needed access to the ClientAppDelegate's navController outlet, I had to add an object from the Library which I changed its class to ClientAppDelegate (kind of what happens in MainApplication.xib). I don't know if this is correct. Also, am I supposed to initialize navController in ClientAppDelegate's applicationDidFinishLaunching()? Can you tell what I'm doing wrong?
Thanks,
Tiberiu
I'm new to the iPhone programming world and I have an app that I've been trying to get to work for a week with no success. I wish I could be articulate and ask my question without including code, but I can't do it. (I also hate looking at other people's code in threads...).
I'm trying to build an app that includes a UITabBarController and a UINavigationController. I have seen examples on how to get this working in Interface Builder, but I want to do it programatically. I have created a Tab Bar Application and in MainWindow.xib I correctly hooked up 5 View Controllers.
In my ClientAppDelegate.h file, I have:
Code:
IBOutlet UIWindow *window;
IBOutlet UITabBarController *rootController;
IBOutlet UINavigationController *navController;
and
applicationDidFinishLaunching()
...
//navController = [[UINavigationController alloc] init];
//navController = [[UINavigationController alloc] initWithNibName:@"WizardView" bundle:nil];
[window addSubview:rootController.view];
My second View Controller (WizardViewController) has the following code:
viewDidLoad()
...
ClientAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *navController = delegate.navController;
[self.view addSubview:navController.view];
[super viewDidLoad];
I created a separate nib file (WizardView.xib) which contains the following:
1. File's owner - hooked up to WizardViewController
2. view - connected to WizardViewController's view
3. a NavigationController whose class type is WizardNavigationController
4. a ClientAppDelegate, whose navController is hooked up to the NavigationController
In my WizardNavigationController (derived from UITableViewController), I have code which populates the table view:
...
didSelectRowAtIndexPath()
{
NSUInteger row = [indexPath row];
AddressViewController *addressViewController = [[AddressViewController alloc] initWithNibName:@"AddressView" bundle:nil];
ClientAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *navController = delegate.navController;
[navController pushViewController:addressViewController animated:YES];
[addressViewController release];
}
Thanks,
Tiberiu
Last edited by a moderator: