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

前端 未结 3 1029
感情败类
感情败类 2021-02-06 14:10

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 \"Emp

3条回答
  •  失恋的感觉
    2021-02-06 14:49

    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 
    

    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.

提交回复
热议问题