设置导航控件的标题

发布于 2024-12-09 02:08:13 字数 297 浏览 0 评论 0原文

我将基于窗口的应用程序转换为基于导航的应用程序,但我无法设置导航栏的标题。

controller = [[bookDisplayViewController alloc] initAndCreateView];

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller];
nav.title=@"Application";
[window addSubview:nav.view];

I converted window based application into navigation based but I am not able to set the title for the navigation bar.

controller = [[bookDisplayViewController alloc] initAndCreateView];

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller];
nav.title=@"Application";
[window addSubview:nav.view];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长安忆 2024-12-16 02:08:13

您可以将其放入

self.navigationItem.title = @"YourName";

另一个视图的viewDidLoad中吗?我会尝试这种方式,看看它是否有效。

Is it possible for you to place

self.navigationItem.title = @"YourName";

in the viewDidLoad of the other view? I'd try it that way and see if it works.

ぇ气 2024-12-16 02:08:13

您必须在 UIViewController 中设置标题。试试这个:


controller.navigationItem.title=@"Application";

事实上,苹果文档中 UINavigationItem 的“title”属性指出:

title
A localized string that represents the view that this controller manages.

@property(nonatomic, copy) NSString *title
Discussion
Subclasses should set the title to a human-readable string that represents the view to the user. If the receiver is a navigation controller, the default value is the top view controller’s title.

Availability
Available in iOS 2.0 and later.

You must set the title from within the UIViewController. Try this:


controller.navigationItem.title=@"Application";

Infact apple docs on UINavigationItem for the "title" property states that:

title
A localized string that represents the view that this controller manages.

@property(nonatomic, copy) NSString *title
Discussion
Subclasses should set the title to a human-readable string that represents the view to the user. If the receiver is a navigation controller, the default value is the top view controller’s title.

Availability
Available in iOS 2.0 and later.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文