navigationItem.backBarButtonItem not working? Why is the previous menu still showing as the button?(navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮?)
问题描述
尝试在下钻导航控制器中自定义我的后退按钮.
Trying to customize my back button in a drilldown navigation controller.
在我的一个视图控制器上,我有一个 Add 按钮,代码以编程方式生成一个新的 UIViewController:
On my one view controller I have an Add button where the code programatically generates a new UIViewController:
- (void)add:(id)sender
{
MyAddViewController *addController = [[MyAddViewController alloc] initWithNibName:@"MyAddViewController" bundle:nil];
[self.navigationController pushViewController:addController animated:YES];
[addController release];
}
这有效,当我单击添加按钮时,它会向下钻取到新视图.在 MyAddViewController.m 的 viewDidLoad 方法中,我有:
This works and when I click the add button it drills down into the new view. Inside the viewDidLoad method of MyAddViewController.m I have:
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil] autorelease];
但这不起作用.导航控制器中的后退按钮仍然是堆栈上前一个视图控制器的 title.这条线似乎什么也没做.我错过了什么吗?
But this isn't working. The back button in the navigation controller remains the title of the previous view's controller on the stack. It seems that line does nothing. Did I miss something?
谢谢
推荐答案
这仅适用于具有 self.navigationItem.backBarButtonItem 的 viewController 之后的每个子节点.
This will only work on each child after the viewController that has self.navigationItem.backBarButtonItem.
这篇关于navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮?
基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
