如何正确设置UIViewController的navigationController标题? [英] How do I correctly set a UIViewController's navigationController title?
本文介绍了如何正确设置UIViewController的navigationController标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试以下代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Thing *sub = [[subscriptions objectAtIndex:indexPath.row] retain];
StoriesViewController *thing = [[StoriesViewController alloc] initWithThing:sub];
thing.navigationController.title = sub.title;
[self.navigationController pushViewController:thing animated:YES];
[thing release];
[sub release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
我认为这是你正确设置推动控制器的标题的方法。我尝试了thing.title但是设置了TabBarItem的标题。
I thought this is how you correctly set the title for pushing the controller. I tried thing.title however that was setting the TabBarItem's title instead.
推荐答案
thing.navigationItem.title = sub.title;
或中的StoriesViewController.m文件中的viewDidLoad
方法:
self.navigationItem.title = sub.title
这篇关于如何正确设置UIViewController的navigationController标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文