zoukankan      html  css  js  c++  java
  • iOS 如何使用TabbarController

    xcode中给我内置很多app模版,不过很多时候我们需要更加灵活的初始化项目。下面我就简单介绍一下,如何从0开始制作一个tabbar app。

    1. 创建个项目,由于我们从头开始写程序,因此理论上对模版没有特殊的要求。这里我们选择Single View Application模版。
    2. 创建完成后,我们就可以开始写程序了。iOS app程序都是以一个UIWindows为基础的,因此我们只需创建好一个VC然后将windows的rootViewController设置为当前VC即可。下面是代码

    '''

    -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    WordListVC * oneVC=[[WordListVC alloc] init];
    WordListVC * twoVC=[[WordListVC alloc] init];
    WordListVC * threeVC=[[WordListVC alloc] init];
    oneVC.tabBarItem.title = @今日计划;
    oneVC.tabBarItem.image = [UIImage imageNamed:@plan-icon];
    twoVC.tabBarItem.title = @词汇列表;
    twoVC.tabBarItem.image = [UIImage imageNamed:@list-icon];
    //self.placeholderVC.tabBarItem.title = @";
    threeVC.tabBarItem.title = @
    生疏词汇;
    threeVC.tabBarItem.image = [UIImage imageNamed:@
    unfamiliar-words-icon];
    //pvc.tabBarItem.title = @
    设置;
    //pvc.tabBarItem.image = [UIImage imageNamed:@
    settings-icon"];
    UITabBarController *tabbarController = [[UITabBarController alloc]init];
    tabbarController.delegate = self;
    [tabbarController setViewControllers:@[oneVC,twoVC,threeVC]];
    [tabbarController setSelectedIndex:0];
    tabbarController.tabBar.barTintColor = [UIColor whiteColor];
    self.tabbarController = tabbarController;
    self.window.rootViewController=self.tabbarController;
    return YES;
    }
    '''

  • 相关阅读:
    BZOJ 5418: [Noi2018]屠龙勇士 EXCRT+multiset
    CF1033D Divisors Pollard-rho
    BZOJ 3782: 上学路 Lucas+ExCRT+容斥+dp
    BZOJ 1951: [Sdoi2010]古代猪文 ExCRT+欧拉定理+Lucas
    Activiti介绍(一)
    Centos7卸载FastDFS6.1卸载(六)
    FastDFS整合SpringBoot(五)
    FastDFS整合nginx模块报错
    SpringBoot怎么访问html文件
    FastDFS整合普通Maven项目(四)
  • 原文地址:https://www.cnblogs.com/springday/p/7439665.html
Copyright © 2011-2022 走看看