• UITabBarController


    #import <UIKit/UIKit.h>
    
    @interface TabBarViewController : UITabBarController
    
    + (TabBarViewController *)sharedTabBarController;
    
    @end
    
    
    #import "TabBarViewController.h"
    #import "FirstViewController.h"
    #import "SecondViewController.h"
    #import "ThirdViewController.h"
    
    @interface TabBarViewController ()
    
    @end
    
    static TabBarViewController *_tabBarController;
    
    @implementation TabBarViewController
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    
    + (TabBarViewController *)sharedTabBarController
    {
        if (_tabBarController == nil) {
            _tabBarController = [[TabBarViewController alloc]init];
        }
        return _tabBarController;
    }
    
    - (id)init
    {
        self = [super init];
        if (self) {
            FirstViewController *firVC = [[FirstViewController alloc]init];
            firVC.title = @"First";
            UINavigationController *firNaviController = [[UINavigationController alloc]initWithRootViewController:firVC];
            
            SecondViewController *secVC = [[SecondViewController alloc]init];
            secVC.title = @"Second";
            UINavigationController *secNaviController = [[UINavigationController alloc]initWithRootViewController:secVC];
            
            ThirdViewController *thiVC = [[ThirdViewController alloc]init];
            thiVC.title = @"Third";
            UINavigationController *thiNaviController = [[UINavigationController alloc]initWithRootViewController:thiVC];
            
            firNaviController.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"First" image:nil tag:0];
            secNaviController.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"Second" image:nil tag:1];
            thiNaviController.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"Third" image:nil tag:2];
            
            NSArray *controllerArray = [[NSArray alloc]initWithObjects:firNaviController,secNaviController,thiNaviController, nil];
            self.viewControllers = controllerArray;
        }
        return self;
    }
  • 相关阅读:
    DRT移植各种成熟稳定的C工具包到DELPHI
    Delphi Event Bus 2.1发布了
    这个真恶心人!Delphi 11.1的Listview不能继承DynamicAppearance
    使用TBufferedLayout提升UI的显示效率
    Delphi 格式化代码调整每行的宽度
    Delphi 11.1 试用报告
    java POI Excel 导入
    Json在线生成Java实体类 http://www.esjson.com/jsontopojo.html
    正则校验记录先记录日后补充
    轻松搞懂POST与PUT的区别
  • 原文地址:https://www.cnblogs.com/joesen/p/3600820.html
Copyright © 2020-2023  润新知