Create uiTabBarController programmatically

前端 未结 4 1478
被撕碎了的回忆
被撕碎了的回忆 2021-02-14 09:23

I want to create a UIView for a UITabBarController

Here is my code for the .h file :

@interface TE : UIViewContro         


        
4条回答
  •  囚心锁ツ
    2021-02-14 09:51

    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;
    
    }
    

提交回复
热议问题