禁用后退按钮,并在导航视图控制器中放置取消按钮 - 像联系人iPhone应用程序 [英] Disabling back button and put Cancel button in navigation view controller -- like contacts iPhone application
问题描述
我有一个导航视图控制器,在导航堆栈中有3个视图控制器。现在在第三个和最顶部的可见视图控制器,我有一个默认的后退按钮进来。
I have a navigation view controller and there are 3 view controllers in the navigation stack. Now on the third and top most visible view controller I have a default back button coming in.
我需要把这个视图控制器在编辑模式,我做了...现在的要求是取消按钮作为左侧栏按钮项而不是后退按钮。
I need to bring this view controller in edit mode which I did... Now the requirement is to have a cancel button as the left bar button item instead of back button.
这与iPhone的联系人应用程序给出的功能类似,
This is similar to the functionality given by contacts application of iPhone where you edit a particular contact.
任何线索如何实现这一点?
Any clue how to achieve this?
推荐答案
要隐藏后退按钮并添加左侧栏按钮,请使用 -
To hide back button and add a left bar button use-
[self.navigationItem setHidesBackButton:TRUE];
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector()];
[self.navigationItem setLeftBarButtonItem:leftBarButton];
[leftBarButton release];
然后以编程方式返回到上一个视图控制器,可以执行 -
And then to programmatically return to the previous view controller, you can do-
[self.navigationController popViewControllerAnimated:YES];
这篇关于禁用后退按钮,并在导航视图控制器中放置取消按钮 - 像联系人iPhone应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!