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 Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 06-14-2011, 10:18 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 2
timothy is on a distinguished road
Default Need help with simple UITabBarController app

Hi, I'm completely new and I'm simply trying to make an iPhone app with two tabs on the bottom (for learning purposes), one for each of my two custom views. I created an Xcode "view-based-application" project and then created two subclasses of UIViewController (for my two custom views). I then went to the associated xib files for each UIViewController subclass (which I named MyVC1 and MyVC2) and put a label in each one with different text so I could tell if it worked or not. I then put the following code into my projectAppDelegate.m class:

Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    MyVC1 *vc1 = [[MyVC1 alloc] init];
    MyVC2 *vc2 = [[MyVC1 alloc] init];
    
    UITabBarController *tbc = [[UITabBarController alloc] init];
    tbc.viewControllers = [NSArray arrayWithObjects: vc1, vc2, nil];
    [vc1 release];
    [vc2 release];
    

     
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    
    [self.window addSubview:tbc.view];
    [self.window makeKeyWindow];
    
    return YES;
}
These are the only changes I made. When I run this, the simulator shows the two tabs at the bottom, but when I click them, the labels in MyVC1 and MyVC2 don't show up (it's just white). Can someone please walk me through what I have to do to get this simple app working? Do I need to change my code? Do I need to make some associations somewhere in InterfaceBuilder with my MyVC1.xib and MyVC2.xib? Any help would be appreciated.

EDIT: I just realized why the label wasn't showing up. I alloced MyVC1 twice instead of MyVC2 the second time and MyVC2 was the only one I put a label in. Sorry for the dumb mistake. But I still feel like I'm not quite getting something or that I'm doing something wrong. Can someone tell me what they would've done differently to achieve what I was trying to achieve? Thanks.

Last edited by timothy; 06-14-2011 at 10:29 AM. Reason: realized my mistake
timothy is offline   Reply With Quote
Old 06-14-2011, 10:31 AM   #2 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 2
timothy is on a distinguished road
Default

another question, why doesn't it seem to make any difference whether I leave the following code in or not (from my code up above):

Code:
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
What exactly is this code used for? And why doesn't it seem to change anything when I comment it out? Thanks.
timothy 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: 417
11 members and 406 guests
AppleDev, chemistry, Emy, Gi-lo, ipodphone, mistergreen2011, pipposanta, QuantumDoja, Retouchable, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,924
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

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