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;
    }
  • 相关阅读:
    ABAP Webdynpro Interface View的用法
    ABAP Webdynpro的跟踪工具WD_TRACE_TOOL
    git 速查
    Python 解析含有命名空间(xmlns)的xml文件(基于ElementTree)
    完全显示DataFrame中行、列内容
    解决Jupyter Notebook中for循环输出DataFrame不够美观
    git配置别名
    元素可拖拽(移动端与pc端)
    pointer network和recursive神经网络
    ELMO,BERT和GPT简介
  • 原文地址:https://www.cnblogs.com/joesen/p/3600820.html
Copyright © 2011-2022 走看看