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;
    }
  • 相关阅读:
    微信小程序
    svn
    当滑动条滑动到某一位置触发js
    css固定页面
    css三级菜单
    h5时钟
    DOM节点
    应用r.js来优化你的前端
    浅谈javascript中的作用域
    javascript 中的 arguments,callee.caller,apply,call 区别
  • 原文地址:https://www.cnblogs.com/joesen/p/3600820.html
Copyright © 2011-2022 走看看