更改UIBackButtonItem标题 [英] Changing the UIBackButtonItem title

查看:101
本文介绍了更改UIBackButtonItem标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于navigationController的应用程序。我想更改根视图控制器的后退按钮的标题。我试过下面的代码在rootViewController的viewDidLoad方法,但没有成功:

I have a navigationController-based app. I want to change the title of the back button for the root view controller. I have tried the following code in the rootViewController's viewDidLoad method, but no success:

self.navigationItem.backBarButtonItem.title = @"Back";

任何想法?

推荐答案

返回按钮的标题是:


  1. 上一个视图控制器的标题

  2. 上一个视图控制器的导航项后退按钮的名称

如果您正在设置当前查看控制器的导航项目,您没有设置在当前视图中显示的按钮。您实际上设置了后退按钮,如果您从其中推送另一个视图控制器将使用。

If you are setting the back button for the current view controller's navigation item you are not setting the button that get's displayed in the current view. You are in fact setting the back button that will be used if you push another view controller from it.

这篇关于更改UIBackButtonItem标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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