iPhone是所有视图控制器的标题 [英] iPhone one title for all view controllers
问题描述
我有一个带标签栏控制器的应用程序(带有4个视图控制器),它包含一个导航控制器。所有这些都是以编程方式创建的。
我的问题:
有没有办法为所有视图控制器设置一个导航栏标题?例如:当我切换标签时,标题是相同的。对我来说理想的解决方案是在app delegate文件中设置标题。非常感谢
I have an app with tab bar controller (with 4 views controller) and it contains a navigation controller. All of this was create programmatically. My question: Is there a way how to set one navigation bar title for all view controllers ? For example: When i switch tabs, title is the same. Ideal solution for me is set title in app delegate file. Thanks a lot
推荐答案
如果您知道将有4个视图控制器,只需执行 self。 title = @你的标题;
如果你想改变你的标题一次并让它们全部改变,只需创建一个静态全局或使用plist。并将代码放在 viewDidAppear
下,以便每次都刷新。不需要做太复杂的事情:)
If you know that there will be exactly 4 views controller, just do self.title = @"your title";
If you want to change "your title" once and have them all changed, just create a static global or use plist. And put the code under viewDidAppear
so that it refreshes every time. No need to do anything too complex :)
这篇关于iPhone是所有视图控制器的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!