gpt4 book ai didi

ios - UINavigation 标题不显示?

转载 作者:行者123 更新时间:2023-11-28 22:35:04 25 4
gpt4 key购买 nike

这在我看来确实加载了。完全没有显示标题?我有一个 UITabBar,UITabBar 内有一个 UITableView 和 UInavigationBar。

//Creates navigation bar.
UINavigationBar *myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
myNavBar.barStyle = UIBarStyleBlack;
myNavBar.topItem.title = @"My Title";

[self.view addSubview:myNavBar];

最佳答案

myNavBar.topItem.title = @"My Title";

不起作用,因为 topItem 为 nil,因为没有项目。您需要添加 UINavigationItem

self.title = @"Some Title";

不起作用,因为 UINavigationController 获取了 UIViewController 的标题,而这里没有 UINavigationController

self.navigationItem.title=@"My Title"";

不起作用,因为 navigationItem 为 nil。

解决方案:

使用 -[UINavigationBar pushNavigationItem:animated:]-[UINavigationBar setItems:]< 添加项目(并在 UINavigationItem 中设置标题)/

关于ios - UINavigation 标题不显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16321889/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com