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 中未显示简单标题
基础教程推荐
- Android Volley - 如何动画图像加载? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
