Create uiTabBarController programmatically

前端 未结 5 2488
隐瞒了意图╮
隐瞒了意图╮ 2021-02-14 09:06

I want to create a UIView for a UITabBarController

Here is my code for the .h file :

@interface TE : UIViewContro         


        
5条回答
  •  萌比男神i
    2021-02-14 09:34

    You say above that you don't want to create the tabBarController in the appDelegate. Why not? Where else would you create it? The tabBarController has to be the root view controller and cannot be a child of any other view controller.

    Btw, make sure you implement:

    - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    
        NSUInteger tabIndex = [tabBarController.viewControllers indexOfObject:viewController];
    
        if (viewController == [tabBarController.viewControllers objectAtIndex:tabIndex] ) {
             return YES;
        }
    
        return NO;
    
    }
    

提交回复
热议问题