如何判断何时在 UINavigationControllerStack 中按下后退按钮

2023-06-12移动开发问题
2

本文介绍了如何判断何时在 UINavigationControllerStack 中按下后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

是否可以检查 UINavigationController 堆栈中何时按下后退按钮?我尝试向 self.navigationItem.backBarButtonItem 添加动作和目标,但无济于事.

Is it possible to check when the back button is pressed in a UINavigationController stack? I've tried adding a action and target to self.navigationItem.backBarButtonItem to no avail.

有人有解决办法吗?

推荐答案

你可以试试我的方法:

在你的 ViewController 中写入:

Write in your ViewController:

UIBarButtonItem *backBt = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"imageNameOfBackButton"] style:UIBarButtonItemStyleBordered target:self action:@selector(backBt_touch:)];
self.navigationItem.leftBarButtonItem = backBt;

以及动作方法:

- (void)backBt_touch:(id)sender {
  [self.navigationController popViewControllerAnimated:YES];
}

你必须拍一张你想要的后退按钮的照片.

You have to take a photo of back button you want.

viewController弹出时隐藏后退按钮的动画和iOS的不一样!

Animation of hiding back button when viewController is popped is not the same animation of iOS!

P/s: 我已经从模拟器中得到它.希望有用!:)

P/s: I've get it from simulator. Hope it useful! :)

这篇关于如何判断何时在 UINavigationControllerStack 中按下后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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