Search code examples
iphoneuitabbarcontrollermultiple-views

Loading Tab Controller View in Window Based iPhone App


I am learning how to create apps with multiple views using the Window-based application template. I am trying to implement a tab bar but when my view loads, it is a blank. I realize it could be an issue between versions of iPhone SDK or Xcode. I am using the latest version of both (iOS 4.3 and Xcode 4.0).

My current code is as follows:

.h file:

@interface iBountyHunterAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *tabcontroller;

}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabcontroller;

.m file:

@synthesize window;
@synthesize tabcontroller;
- (void)applicationDidFinishLaunching:(UIApplication *)application {    

// Override point for customization after app launch    
[window addSubview:tabcontroller.view];
[window makeKeyAndVisible];

}

In the sample code I downloaded, this worked fine. I can't figure out where the problem is and any suggestions would be greatly appreciated.


Solution

  • So I think I figured it out. Due to the lack of the UIWindow *window in the ApplicationDelegate.h @interface:

    I had to reference [self.window addSubview:tabcontroller.view]; in my application didFinishLaunching method,

    rather than just [window addSubview:tabcontroller.view];

    Thanks for the assistance.