简体   繁体   English

UINavigationBar注册UIScrollView的触摸

[英]UINavigationBar registering touches for UIScrollView

I have created an app wherein I have a large scroll view (two page heights), and the navigation bar is visible. 我创建了一个应用程序,其中具有较大的滚动视图(两个页面高度),并且导航栏可见。 Further, I have it setup so that the scroll view starts off scrolled to the bottom page, and touches below the 30px mark are not registered by the UIScroll view (eg if you touch further than 30px below the nav bar, you will be able to press buttons but NOT scroll the UIScrollView). 此外,我对其进行了设置,以便滚动视图开始滚动到底部页面,并且UIScroll视图未注册30px标记以下的触摸(例如,如果您在导航栏下方触摸了30px以上的像素,则可以按下按钮,但不滚动UIScrollView)。 This all works excellently and allows me to make it seem like you are pulling down a window from above, all and all a neat effect. 所有这些都表现出色,让我看起来像是您从上方拉下窗户,所有这些效果都很好。

The problem is that in use case testing, many users seem to be tapping too high (hitting the UINavigationBar) and thus their swipe gestures to try to pull down the window aren't being read. 问题在于,在用例测试中,许多用户似乎敲击得太高(击中UINavigationBar),因此无法读取他们试图拉下窗口的划动手势。 Basically, if the touch starts on the nav bar, the entire gesture is ignored. 基本上,如果在导航栏上开始触摸,则整个手势都将被忽略。 This leads to users getting either frustrated (knowing that they should be able to pull down the window but being unable to) or thinking that the pull down has been disabled for some reason. 这会导致用户感到沮丧(知道他们应该能够拉下窗口,但无法这样做),或者认为由于某种原因禁用了下拉菜单。

I'd like to implement a way such that if the user's touch starts from within the UINavigationBar but isn't on one of the navigation buttons, the touch is passed down to the UIScrollView. 我想实现一种方法,如果用户的触摸从UINavigationBar内开始但不在导航按钮之一上,则将触摸向下传递到UIScrollView。 Is this possible, and if so, how would I go about doing it? 这可能吗?如果可以,我将如何去做呢?

Try using custom navigation bar. 尝试使用自定义导航栏。 Inherit from UINavigation bar and then add a sub view where you want and add a gesture there. 从UINavigation栏继承,然后在所需的位置添加子视图并在其中添加手势。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM