Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-11-2010, 09:10 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 177
skinrock is on a distinguished road
Default Adding UITabBarController from xib as subview

The post title might not be the correct terminology, so I'll try and explain what I'm trying to accomplish.

I'm trying to build an app that utilizes a separate login view from the main app view. The reason is because the login screen is just a UITableView and once you login, you are presented with a UITabBar based view. The idea is that when you login, it does a flip transition to load the logged in part of the app.

My approach is to launch the app with somewhat of a "placeholder" UIView, which creates the login and app views like such:

Code:
UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.containerView = localContainerView;
[localContainerView release];

self.loginController = [[LoginController alloc] initWithNibName:@"LoginView" bundle:nil];
self.loginController.mainController = self;
self.loginView = (LoginView *)loginController.view;

//[containerView addSubview:loginView];

//self.view = containerView;

self.appController = [[AppController alloc] initWithNibName:@"AppView" bundle:nil];
self.appController.mainController = self;
self.appView = (AppView *)appController.view;

[containerView addSubview:appView];

self.view = containerView;
The lines that are commented are the lines that would normally show the login view first...this works fine. The problem I am having is when I try to display the AppView. In my AppView.xib, I have a UITabBar with 3 buttons/views. But when I launch the app, it displays a blank UITabBar...no buttons, and a blank view.

In the UITabBarController example, all they are doing to load the view is:

Code:
[window addSubview:tabBarController.view];
Granted, the UITabBarController is in the MainWindow.xib itself, but I am using "initWithNibName" so I don't see why it would behave differently.

Any help would be appreciated, let me know if something doesn't make sense.
skinrock is offline   Reply With Quote
Old 07-11-2010, 09:28 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

You have identified the correct line of code in the template, and that is exactly what you want to do. You don't want the tab bar controller to be a "sub" of anything. They don't like that.

In your app delegate, you will have both your login screen and your tab bar controller. You will add your login screen first. After login credentials are met, you will remove the login screen and then add your tab bar controller.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 07-11-2010, 09:47 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 177
skinrock is on a distinguished road
Default

So does that mean I should have my login and tab bar controllers in the MainView.xib as well (my Main nib is set to MainView.xib)?

It seems like I'm taking a step back...I was hoping to create the login and tab bar controllers in their own .xib files and load them programatically.
skinrock is offline   Reply With Quote
Old 07-11-2010, 09:51 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

There is no real reason to have the tab bar controller be in a separate .xib.

You are basically starting with the tab-based template, and adding a view controller to MainWindow.xib. However, that does not mean you have to design and manage that view controller within MainWindow.xib. It can be separate.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 07-11-2010, 10:14 PM   #5 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 177
skinrock is on a distinguished road
Default

I was just trying to separate them from a code management point of view.

I mean I see where you're coming from, but I guess it's a little frustrating that I can't figure out why I can't load the tab bar controller from a xib.

I was also trying to manage the swapping of views in another controller, not the AppDelegate file, again just a code management thing - I approached it with a certain structure in mind, and now I have to throw that out.
skinrock is offline   Reply With Quote
Old 07-11-2010, 10:18 PM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

How much structure do you need? It will take 2 minutes to set up your tab bar controller in MainWindow.xib and add your 3 view controllers. If you were doing some weird stuff with delegate methods, copy-paste them.

If this is truly a big deal, then I'd have to question your original intended approach.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 341
16 members and 325 guests
akphyo, alexP, appservice, cgokey, EXOPTENDAELAX, flamingliquid, guusleijsten, mariano_donati, ohmniac, Paul Slocum, PavelSea, SLIC, Sloshmonster, Sonuye857, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:37 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0