Custom UITabBarController and UINavigationController

后端 未结 4 525
心在旅途
心在旅途 2020-12-22 05:04

I\'m developing an app for iOS5 and up and I don\'t use storyboards or IB. I\'m creating a custom UITabBarController and in my AppDelegate I\'m put

4条回答
  •  暖寄归人
    2020-12-22 05:25

    Refer to my answer here:
    UITabBarController Issue

    if(!self.tabBarController)
        self.tabBarController = [[UITabBarController alloc] init];
    
    self.tabBarController.delegate=self;
    
    NSMutableArray *localcontrollerarray = [[NSMutableArray alloc] initWithCapacity:2];
    
    UIViewController *viewController1 = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
    
    UINavigationController *navi1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
    
    [localcontrollerarray addObject:navi1];
    
    UIViewController *viewController2 = [[ScanViewController alloc] initWithNibName:@"ScanViewController" bundle:nil];
    
    UINavigationController *navi2 = [[UINavigationController alloc] initWithRootViewController:viewController2];
    
    [localcontrollerarray addObject:navi2];
    
    self.tabBarController.viewControllers = localcontrollerarray;
    
    [self.window addSubview:self.tabBarController.view];
    

提交回复
热议问题