self.title sets navigationController and tabBarItem#39;s title? Why?(self.title 设置navigationController 和tabBarItem 的标题?为什么?)
问题描述
我在 UIViewController 中为我的一个标签执行此操作:
I do this in a UIViewController for one of my tabs:
self.title = @"Welcome";
但是,它会覆盖我对 tabBarItem 的所有内容.我试过了:
However, it's overwriting whatever I have for the tabBarItem. I have tried:
self.tabBarItem.title = @"Home";
和
[self.tabBarItem initWithTitle:@"Home" image:[UIImage imageNamed:@"iconHome.png"] tag:0];
但是,self.title 仍然会覆盖 tabBarItem,无论我是否在 设置标题之后尝试后两段代码.代码甚至可以正常运行,但是 self.tabBarItem.title 或 initWithTitle 什么也没做?
But still, self.title overwrites the tabBarItem, regardless of whether I am trying the two latter pieces of code after the title has been set. The code even runs without errors, but the self.tabBarItem.title or initWithTitle doesn't do anything?
推荐答案
好的,我想通了!这就是我正在做的事情:
OK, I figured it out! Here's what I am doing:
self.title = @"Title for TabBarItem"; // TabBarItem.title inherits the viewController's self.title
self.navigationItem.title = @"Title for NavigationBar";
navigationBar 将继承 self.title,除非另外使用 self.navigationItem.title
the navigationBar would inherit self.title, unless otherwise set using self.navigationItem.title
这篇关于self.title 设置navigationController 和tabBarItem 的标题?为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:self.title 设置navigationController 和tabBarItem 的标题?为什么?
基础教程推荐
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
