Question : iPhone app: TabBarController and a first View

Hi experts,

I'm new to app development and have played around a bit with some examples but can only really start to understand a technology by plunging in and trying to make a real app.

What I want to achieve is the following. I need to get an idea of the right way to achieve what I want from the app, and not build it the wrong way from the start.

The app needs to have a first View which is like a welcome screen. It'll have 4 buttons on it. Each of these buttons will load a new view. These 4 views must be part of a tabbarcontroller, so when a user presses button "my details" on the welcome screen, it loads the "my details" view, complete with tabbarcontroller selected on the correct tab. Likewise for each of the other buttons. But the tabbarcontroller must NOT be visible on the welcome screen.

I have created the Window app with 5 ViewControllers. 4 of those are linked to tabs in a tab bar controller which is added to MainWindow.xib and added as a subview to the AppDelegate.m

This loads fine. However, I wish to have a welcome screen with buttons which does not load the tabbar. So I have added a new ViewController (WelcomeViewController) which is loaded at start and does not load the tabbar. What I want is when a button is clicked on this WelcomeViewController, the relevant ViewController is switched to - with the tabbar visible and the relevant tabbar button highlighted.

So far I can get the the first relevant ViewController to load (in this case it's called BookingViewController), but the tabbar is not visible - probably because I'm loading this ViewController as a modal. I think I have this the wrong way round - ideally I want the first view (WelcomeViewController) to load as a modal and then close when one of its buttons are clicked.

I hope this makes sense! Please help!

Here is my code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
AppDelegate.m :-
[window addSubview:tabBarController.view];
WelcomeViewController *aViewController = [[WelcomeViewController alloc] initWithNibName:@"WelcomeViewController" bundle:[NSBundle mainBundle]];
	self.viewController = aViewController;
	[aViewController release];
	[window addSubview:[viewController view]];

AppDelegate.h :-
UITabBarController *tabBarController;
WelcomeViewController *viewController;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, retain) WelcomeViewController *viewController;

WelcomeViewController.m :-
-(IBAction)clickBooking:(id)sender {
BookingViewController *bView = [[BookingViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:bView animated:YES];
}

WelcomeViewController.h :-
-(IBAction)clickBooking:(id)sender;

Answer : iPhone app: TabBarController and a first View

I figured out how to access the appDelegate in which I store the method to switch tabs and call them from my ViewController. Thanks for the advice but this seemed cleaner and easier.
Random Solutions  
 
programming4us programming4us