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的。  有具体知道原因的欢迎评论

  • 相关阅读:
    .net core系列之《.net平台历程介绍以及.net framework和.net core对比》
    C++ 拷贝构造函数
    C++ const引用
    C++ 引用和指针
    C++ 将派生类赋值给基类(向上转型)
    C++ 虚继承
    C++ 基类和派生类的构造函数以及析构函数
    C++ 类继承时的作用域嵌套和对象内存模型
    C++ private + protected + public
    C++ const成员变量、成员函数和对象
  • 原文地址:https://www.cnblogs.com/isItOk/p/8479684.html
Copyright © 2011-2022 走看看