简单标题未显示在UINavigationController中 [英] Simple Title not showing up in UINavigationController

查看:80
本文介绍了简单标题未显示在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中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆