简体   繁体   English

UISwipeGestureRecognizer和UIScrollView

[英]UISwipeGestureRecognizer and UIScrollView

I have a vertical scrollview(no horizontal scrolling possible) and my tab bar is hidden by default. 我有一个垂直滚动视图(不可能水平滚动),并且默认情况下我的标签栏是隐藏的。 However, you can, by swiping up in the bottom area of the screen, pull the tab bar up.(content needs a lot of vertical space) There is my dilemma: I want to be able to detect a swipe up gesture in the bottom area of my scrollview, without the scrollview scrolling down. 但是,您可以通过向上滑动屏幕底部来向上拉动标签栏。(内容需要大量垂直空间)我的困境是:我希望能够检测到底部的向上滑动手势我的滚动视图的区域,而滚动视图没有向下滚动。 So I was thinking of putting a transparent view over that bottom area, to only detect that swipe up. 因此,我正在考虑在该底部区域放置透明视图,以仅检测到向上滑动。 But this has the problem that, although that view is transparent, all my touch events are intercepted by that view and are not forwarded to the scrollview. 但这有一个问题,尽管该视图是透明的,但我所有的触摸事件都被该视图拦截,而没有转发到滚动视图。

Is it possible to only forward taps to my scrollview, so I am still able to, for example, press buttons that are currently in the bottom area of my scrollview? 是否只能将水龙头前进到我的滚动视图,所以例如,我仍然可以按下当前在滚动视图底部的按钮?

Strange problem I know, but I wasn't able to find a similar problem with a working solution. 我知道奇怪的问题,但是在有效的解决方案中我找不到类似的问题。

My scrollview code: 我的scrollview代码:

scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 30, 320, self.view.frame.size.height - 50)];
scrollView.showsVerticalScrollIndicator = YES;
scrollView.tag = 0;
scrollView.backgroundColor = [UIColor clearColor];
scrollView.delegate = self;
scrollView.maximumZoomScale = 1.0;
scrollView.clipsToBounds = NO;
scrollView.minimumZoomScale = 1.0;
scrollView.scrollEnabled = YES;
scrollView.pagingEnabled = YES;
scrollview.contentSize = CGMakeSize(320, xxxx);

My transparent view code: 我的透明视图代码:

UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc]
                                      initWithTarget:self
                                      action:@selector(showTabBar)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
UIView *swipeLayer = [[swipeLayer alloc] initWithFrame:CGRectMake(30, self.view.frame.size.height - 80, 260, 40)];
[hideButtonSwipeActions addGestureRecognizer:swipeUp];
[hideButtonSwipeActions setBackgroundColor:[UIColor clearColor]];
//[hideButtonSwipeActions setUserInteractionEnabled:NO];

...
[swipeUp release];

Thank you very much for any help :) 非常感谢您的帮助:)

也许您是否使用触摸(0,480)的坐标来跟踪视图底部?

Have you tried setting the bottom UIView's userInteractionEnabled property to NO? 您是否尝试过将底部UIView的userInteractionEnabled属性设置为NO? It should still allow your swipe recognizer to work, however it should stop the view from swallowing normal touches. 它仍应允许您的滑动识别器正常工作,但是它应阻止视图吞噬正常的触摸。

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

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