Frage

The question is similar to this one, but it was created when Xcode 5 doesn't exist. And that question is still not answered. There are also similar questions about how to delete the storyboard, but they are about navigation controller, not tab bar controller.

My action order:

  1. create tabbed applcation

  2. delete all the storyboard files

  3. delete storyboards from .plist

  4. create UITabBarController subclass and edit xib

  5. change the app delegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    BKTabController *navVC = [[BKTabController alloc] initWithNibName:@"BKTabController" bundle:nil];
    self.window.rootViewController = navVC;
    [self.window makeKeyAndVisible];

    return YES;
}

The result is black screen with a gray place instead of tab bar.

Where is the mistake?

War es hilfreich?

Lösung

You see a black screen because your tab bar is empty, so you have to add ViewController to your TabController.

Modify you AppDelegate like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    BKTabController *navVC = [[BKTabController alloc] initWithNibName:@"BKTabController" bundle:nil];
    self.window.rootViewController = navVC;

    FirstViewController* firstView = [[FirstViewController alloc]initWithNibName:nil bundle:nil];
    firstView.title = @"FIRST"; //THIS WILL BE THE TITLE OF YOUR FIRST TAB

    SecondViewController* secondView = [[SecondViewController alloc]initWithNibName:nil bundle:nil];
    secondView.title = @"SECOND";//THIS WILL BE THE TITLE OF YOUR SECOND TAB

    //ADD VIEW CONTROLLER TO YOUR TAB CONTROLLER
    self.tabBarController.viewControllers = @[firstView,secondView];

    [self.window makeKeyAndVisible];
    return YES;
}

Summary:

  1. Add two o more new ViewControllers to you Xcode project (ex FirstViewController, SecondViewController).
  2. Modify you app delegate by adding this ViewControllers to your Tab bar controller.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top