Simple Title not showing up in UINavigationController(UINavigationController 中未显示简单标题)
问题描述
我查看了所有类似/相关的问题,但没有一个 a) 完全是我的问题,或者 2) 解决方案不起作用.
I have looked at all of the similar/related questions, but none either a) are exactly my problem or 2) the solutions just don't work.
在我的 appDelegate.m 中有 didFinishLaunchingWithOptions
In my appDelegate.m I have in didFinishLaunchingWithOptions
JCGRootNavigationController *rnc = [[JCGRootNavigationController alloc] init];
self.window.rootViewController = rnc;`
JCGRootNavigationController 是 UINavigationController 的子类
JCGRootNavigationController is a subclass of UINavigationController
@interface JCGRootNavigationController : UINavigationController`
在 JCGRootNavigationController.m 中:
In JCGRootNavigationController.m:
@implementation JCGRootNavigationController
-(instancetype) init {
self = [super init];
self.view.backgroundColor = [UIColor lightGrayColor];
self.navigationItem.title = @"MY TITLE";
return self;
}
而且标题不会显示.我看到导航栏,但没有标题.看起来多年来很多人都遇到过同样的问题.也许一个简单的答案将有助于消除所有的困惑.这真是令人难以置信的令人沮丧.
And the title just won't display. I see the Navigation Bar, but no title. Looks like lots of people over the years have had this same problem. Maybe a simple answer will help clear up all of the confusing. This is so incredibly frustrating.
推荐答案
UINavigationController 自动显示它正在显示的 UIViewController 子类的标题.它通过查看 UIViewController 或 UIViewController 子类的 navigationItem.title 属性来实现.基本上 UINavigationController 没有标题.
UINavigationController automatically shows the title of the UIViewController subclass it is displaying. It does so by looking at the navigationItem.title property of that UIViewController or UIViewController subclass. Basically UINavigationController doesn't have a title.
这篇关于UINavigationController 中未显示简单标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UINavigationController 中未显示简单标题
基础教程推荐
- LocationClient 与 LocationManager 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
