禁用后退按钮并将取消按钮放在导航视图控制器中 - 就像联系人 iPhone 应用程序

2023-06-11移动开发问题
0

本文介绍了禁用后退按钮并将取消按钮放在导航视图控制器中 - 就像联系人 iPhone 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个导航视图控制器,导航堆栈中有 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 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

如何将 32 位 PNG 转换为 RGB565?
How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)...
2024-08-12 移动开发问题
21

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7