How to tell when back button is pressed in a UINavigationControllerStack(如何判断何时在 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 中按下后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何判断何时在 UINavigationControllerStack 中按下后退按钮


基础教程推荐
- Firebase 云消息传递令牌未生成 2022-01-01
- 从 UIWebView 访问元数据 2022-01-01
- UINavigationItem 的持久 rightBarButtonItem 属性 2022-01-01
- Android - 如何在runOnUiThread 中将数据传递给Runnable? 2022-01-01
- 更改 UITableView 部分标题的颜色 2022-01-01
- 在 iOS 7 下 CCMenu 错位 2022-01-01
- EditText 中的 setHintTextColor() 2022-01-01
- 在视图控制器的宽度上水平均匀分布 UIButton 的最简单方法? 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- UINavigationBar 隐藏按钮文本 2022-01-01