zoukankan      html  css  js  c++  java
  • controller.tabBarItem.title = @"11111"不显示

    场景:

    在xcode8.3下  今天在弄工程的时候,发现把之前工程中的tabbar控制器拿过来后,在控制器里面用 controller.tabBarItem.title = @"11111"不显示 

    之前用着一直没问题

    代码如下

    ===============================================

    #pragma mark -

     - (void)viewDidLoad {

        [super viewDidLoad];

        

        [self addChildVc];

        

    }

    -(void)addChildVc

    {

        OneViewController * infoVc = [[OneViewController alloc] init];

        [self addChildVc:infoVc withTitle:@"1" withImage:@"shuju_1" withSelectedImage:@"info"];

     }

    -(void)addChildVc:(UIViewController *)controller withTitle:(NSString *)title withImage:(NSString *)image withSelectedImage:(NSString *)selectedImage

    {

        // 设置子控制器的文字

    //    controller.title = title; // 同时设置tabbar和navigationBar的文字

    //    本工程不需要设置导航的标题,所以不用上一句

        controller.tabBarItem.title = title; // 设置tabbar的文字

    //    controller.navigationItem.title = title; // 设置navigationBar的文字

        

        

    #pragma mark 设置子控制器的 tabBarItem.image

        controller.tabBarItem.image = [UIImage imageNamed:image];

        

        controller.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

        

    #pragma mark 先给外面传进来的小控制器 包装 一个导航控制器

        ZNavigationController *nav = [[ZNavigationController alloc] initWithRootViewController:controller];

    #pragma mark 添加为子控制器

        [self addChildViewController:nav];

        

    }

    ===============================================

    尝试了

    controller.title = title;  和  

    controller.navigationItem.title = title; 

     都可以在tab或者navi上显示相应的标题,唯独用    controller.tabBarItem.title = title; 显示不出来

    挺奇怪

    后来把

        [self addChildVc:infoVc withTitle:@"1" withImage:@"shuju_1" withSelectedImage:@"info"];

     里面的图片shuju_1和info真正加到工程里才可以了

    xcode 等有的时候也有bug,比较怪。具体原因归结为xcode的。  有具体知道原因的欢迎评论

  • 相关阅读:
    Appium+python自动化17-appium1.6在mac上环境搭建启动ios模拟器上Safari浏览器
    Appium+python自动化18-启动iOS模拟器APP源码案例
    Appium+python自动化16-在Mac上环境搭建
    Appium+python自动化14-native和webview切换
    Appium+python自动化15-查看webview上元素(DevTools)
    Appium+python自动化13-appium元素定位
    Appium+python自动化11-AVD 模拟器
    Appium+python自动化12-adb必知必会的几个指令
    Appium+python自动化10-SDK Manager
    jenkins+gitlab配置
  • 原文地址:https://www.cnblogs.com/isItOk/p/8479684.html
Copyright © 2011-2022 走看看