zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    JavaScript实现常用的排序算法
    jQuery学习之路(8)- 表单验证插件-Validation
    jQuery学习之路(7)- 用原生JavaScript实现jQuery的某些简单功能
    jQuery学习之路(6)- 简单的表格应用
    jQuery学习之路(5)- 简单的表单应用
    jQuery学习之路(4)- 动画
    JavaScript常见的五种数组去重的方式
    jQuery学习之路(3)- 事件
    jQuery学习之路(2)-DOM操作
    Docker使用非root用户
  • 原文地址:https://www.cnblogs.com/joesen/p/3600820.html
Copyright © 2011-2022 走看看