self.navigationItem.backBarButtonItem不工作?为什么上一个菜单仍然显示为按钮? [英] self.navigationItem.backBarButtonItem not working ?? Why is the previous menu still showing as the button?

查看:345
本文介绍了self.navigationItem.backBarButtonItem不工作?为什么上一个菜单仍然显示为按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在向下钻取导航控制器中自定义我的后退按钮。

Trying to customize my back button in a drilldown navigation controller.

在我的一个视图控制器上有一个添加编程生成一个新的 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];

但这不工作?导航控制器中的后退按钮仍然是堆栈中上一个View控制器的标题?看起来行什么也不做?我错过了什么?

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.

这篇关于self.navigationItem.backBarButtonItem不工作?为什么上一个菜单仍然显示为按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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