在 NavigationController 中设置后退按钮标题
我正在尝试通过以下方式更改 NavigationController 中的后退按钮标题:
在父控制器中,我将其放入 vieDidLoad 中:
self.title = @"Calendars";
self.navigationItem.backBarButtonItem.title = @"Previous";
但是自从我初始化应用程序以来,该控制器就位于堆栈中:
-(void)applicationDidFinishLaunching:(UIApplication *)application{
navController.viewControllers= [NSArray arrayWithObjects:aController,aBcontroller,nil];
[window addSubview:navController.view];
}
所以,直到我在 bController 中第一次选择后退按钮后,aController 中的 viewDidLoad 才会被调用...
有谁知道当我将其推入堆栈时如何调用 viewDidLoad 吗?或者您知道更改 BackButtom 标题的另一种方法吗?
I'm trying to change Back Button tittle in a NavigationController in the following way:
In the parent controller I put this in vieDidLoad
:
self.title = @"Calendars";
self.navigationItem.backBarButtonItem.title = @"Previous";
But this controller is in the stack since I initialized the app:
-(void)applicationDidFinishLaunching:(UIApplication *)application{
navController.viewControllers= [NSArray arrayWithObjects:aController,aBcontroller,nil];
[window addSubview:navController.view];
}
So, the viewDidLoad in aController is not called until I select the back buttom the first time in the bController...
Does anyone knows how to call viewDidLoad just when I push it into the stack? Or do you know another way to change the BackButtom title?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用以下代码行为您所在的任何 ViewController 设置后退按钮的标题:
You can set the title of the back button for any ViewController you're in with the following line of code:
您应该将代码放在
init
中设置标题和 navigationItem,无需等到视图加载。You should put your code to set up the title and navigationItem in
init
, you don't need to wait until the view is loaded.