No Swipe Back when hiding Navigation Bar in UINavigationController(在 UINavigationController 中隐藏导航栏时不向后滑动)
问题描述
我喜欢将视图嵌入到 UINavigationController 中继承的滑动包.不幸的是,我似乎无法找到隐藏 NavigationBar 的方法,但仍然让触摸屏向后滑动 gesture.我可以编写自定义手势,但我不喜欢而是依赖 UINavigationController 向后滑动 gesture.
I love the swipe pack thats inherited from embedding your views in a UINavigationController. Unfortunately i cannot seem to find a way to hide the NavigationBar but still have the touch pan swipe back gesture. I can write custom gestures but I prefer not to and to rely on the UINavigationController back swipe gesture instead.
如果我在情节提要中取消选中它,则向后滑动不起作用
if I uncheck it in the storyboard, the back swipe doesn't work
或者,如果我以编程方式隐藏它,同样的场景.
alternatively if I programmatically hide it, the same scenario.
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController setNavigationBarHidden:YES animated:NO]; // and animated:YES
}
有没有办法隐藏顶部 NavigationBar 仍然可以滑动?
Is there no way to hide the top NavigationBar and still have the swipe?
推荐答案
一个可行的方法是将 interactivePopGestureRecognizer 的 UINavigationController 委托设置为 nil 像这样:
A hack that is working is to set the interactivePopGestureRecognizer's delegate of the UINavigationController to nil like this:
[self.navigationController.interactivePopGestureRecognizer setDelegate:nil];
但在某些情况下,它可能会产生奇怪的效果.
But in some situations it could create strange effects.
这篇关于在 UINavigationController 中隐藏导航栏时不向后滑动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 UINavigationController 中隐藏导航栏时不向后滑动
基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iOS4 创建后台定时器 2022-01-01
