场景:

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

controller.tabBarItem.title = @"11111"不显示的更多相关文章

  1. iOS 11 导航栏 item 偏移问题 和 Swift 下 UIButton 设置 title、image 显示问题

    html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...

  2. Spring 框架下Controller 返回结果在EasyUI显示

    这几天弄了一下java下的在后台返回数据到jsp页面上的显示: 总结一下: 首先后台方面: @RequestMapping(value="/searchByUserName") @ ...

  3. Activity标题(title)的显示和隐藏

    开发Android应用程序,我们总会遇到Activity的title把显示的内容遮挡了一部分.如果能把它去掉,我们的应用界面就会变得更加简洁,那该多好.下面有两种方法可以去掉: (方法一):通过一句J ...

  4. HTML title属性换行显示的方法

    原文发布时间为:2009-04-22 -- 来源于本人的百度文章 [由搬家工具导入] 解决的方法有两种: 1.将title属性分成几行来写,例如:<a href=#" title=&q ...

  5. iOS 控制器title和tabbar的title设置问题

    iOS 设置tabbarItem的title的是通过 controller.tabBarItem.title = @"标题" iOS 设置导航栏控制器title通过 contoll ...

  6. iOS基础 - 控制器管理

    一.Container 一个iOS的app很少只由一个ViewController组成,除非这个app极其简单.当app中有多个ViewController的时候,我们就需要对这些ViewContro ...

  7. iOS:UI简单的总结

    UI简单总结: 一.常用单例: NSBundle *bundel = [NSBundle mainBundle]; //加载资源 NSFileManager *fm = [NSFileManager  ...

  8. iOS:切换视图的第三种方式:UITabBarController标签栏控制器

    UITabBarController:标签栏控制器 •通过设置viewControllers属性或者addChildViewController方法可以添加子控制器 –NSArray *viewCon ...

  9. iOS开发200个tips总结(一)

    tip 1 :  给UIImage添加毛玻璃效果 func blurImage(value:NSNumber) -> UIImage { let context = CIContext(opti ...

随机推荐

  1. Is there anyway to discover which ip addresses are connected to the db?

    From mongo shell run db.currentOp() to show all active connections or db.currentOp(true) to show all ...

  2. RateLimiter 限流

    @RestControllerpublic class RateLimiterController { private RateLimiter rateLimiter = RateLimiter.cr ...

  3. ASP入门(六)-Response对象

    Response对象可以从服务器向用户发送输出的结果. Response几种常用方法 方法 描述 BinaryWrite 向浏览器输出二进制的内容 Clear 清除已经缓冲的HTML输出 End 停止 ...

  4. 使用jstl报错:Can not find the tag library descriptor for “http://java.sun.com/jstl/core”

    使用jstl报错:Can not find the tag library descriptor for “http://java.sun.com/jstl/core” 出现这个错误的原因是项目中没有 ...

  5. LintCode: Cosine Similarity

    C++ class Solution { public: /** * @param A: An integer array. * @param B: An integer array. * @retu ...

  6. vmware备份

    http://wenku.baidu.com/view/fc317dcc050876323112128d.html vmware vcb文档 http://www.docin.com/p-423555 ...

  7. SQL中Union和UnionAll的使用

    SQL中Union和UnionAll的使用 1.建立一个Student表 ,如下: 2.建立一个Teacher表,如下: 3.使用Union,将去重并组合表,效果: 4.使用Union All,不去重 ...

  8. Jmeter AbstractJavaSamplerClient 案例

    1:首先到apache-jmeter-3.0\lib\ext目录下引用以下两个jar包到Java工程里面 ApacheJMeter_core.jar ApacheJMeter_java.jar 2:新 ...

  9. Java WebSockets

    https://github.com/TooTallNate/Java-WebSocket Java WebSockets This repository contains a barebones W ...

  10. win7下安装matlab后打开出错“error starting desktop”的解决办法

    在matlab快捷图标上右键,选择"还原以前的版本"--"兼容性"选项卡,在"以兼容模式运行这个程序"前面打勾,并选择"windo ...