steps to add tabbarcontroller to AppDelegate using Interface Builder in XCode 4.2 Empty Application template

11,837

Step 1: create new Empty Application template project.
Step 2: add

@property (nonatomic, strong) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, strong) IBOutlet UIWindow *window;

in your app delegate. (dont forget to synthesize these) Step 3: change this line in your app delegate:

@interface AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>

Step 4: modify this method

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window addSubview:[self.tabBarController view]];
[self.window makeKeyAndVisible];
return YES;
}  

Step 5: create a new empty xib. Drag a tab bar controller on to it as well as an empty object.
Set the empty object's class to AppDelegate. Set Files Owner to UIApplication.

Step 6: drag the 'delegate' property from your files owner on to your appdelegate class and drag the tab bar outlet from you appdelegate class to your tabbarcontroller

Step 7: Add a window and drag the 'window' connection from your appdelegate to the window.

Step 8: Dont forget to go into the project settings and set the main-base nib file to the new xib you created.

Thats it. Hope I didn't miss anything.

Share:
11,837
JAHelia
Author by

JAHelia

Updated on June 11, 2022

Comments

  • JAHelia
    JAHelia almost 2 years

    while I'm stuck at this question I cannot find the right steps to add a UITabBarController to the AppDelegate (not programatically) but by using interface builder for the "Empty Application" template, I tried to add a new empty xib file, then dropped uitabbarcontroller into it, but there is no way to link it (from IB) to AppDelegate !! i.e. when I move the blue line from tabbarcontroller object (in document outline) to File's Owner, interface builder shows only the "Delegate" option in the shown list so there is no IBOutlet option in there.

    so, what are the exact steps for adding a tabbarcontroller and connect it to appDelegate using the interface builder way (for the Empty Application template, using XCode 4.2 and IOS 5 SDK) ?

    step1: create new Empty Application template project.

    ... waiting for the next steps...

    thanks so much in advance.