1

嵌入式 UIViewController 上的 navigationItem backBarButtonItem 标题存在问题。我在滚动视图中嵌入 UIViewControllers 以进行分页,并且当我在滚动视图/分页控制器堆栈上推送某些内容时,我想更改后退按钮标题以进行本地化。

这是我试图在 didSelectRowAtIndexPath 中执行的代码:

QueryItemTableViewController *itemView = [self.app.storyboard instantiateViewControllerWithIdentifier:@"QueryItemView"];

self.scrollcontroller.navigationItem.backBarButtonItem.title = @"Test";
[self.scrollcontroller.navigationController pushViewController:itemView animated:YES];

视图 QueryItemTableViewController 已正确推送到导航控制器,但后退按钮的标题仍然是前一个视图的标题。

有什么建议么?

4

3 回答 3

0

Set the navigation title in the first one.. As you push to the next view controller. The back button gets set automatically, with the title you have set for the previous. Now update the Title of the present view controller in the ViewDidLoad .

So simply these are the steps:

Step 1 always set the title for the current view controller in ViewDidLoad to keep uniformity.

step 2 push to the next UIViewController. Everything gets set automatically.

N.B: You wont get any back button for the first view controller (since it is the root view controller). If you need a back button type button there, simply customise a UIBarButtonItem and use it.

于 2014-05-07T09:39:10.113 回答
0

Could you please update the title in ViewDidLoad method of the UIViewController which is being pushed.

于 2014-05-07T09:19:40.877 回答
0

后退按钮的标题将根据用户的设备语言设置自动调整本地化。

于 2019-01-04T15:38:01.080 回答