我有一个垂直滚动视图(没有水平滚动可能),我的标签栏默认隐藏。但是,您可以通过在屏幕的底部区域向上滑动,将标签栏向上拉(内容需要很大的垂直空间) 我的困境是:我希望能够检测到向上滑动的手势我的滚动视图的底部区域,没有滚动视图向下滚动。所以我在考虑在底部区域放置一个透明的视图,以便只检测到这一点。但是这样做的问题在于,虽然该视图是透明的,但我的所有触摸事件都被该视图拦截,并且不会转发到滚动视图。UISwipeGestureRecognizer和UIScrollView
是否有可能只向前滚动到我的滚动视图,所以我仍然能够,例如,按下当前在我的滚动视图底部区域的按钮?
奇怪的问题我知道,但我无法找到工作解决方案的类似问题。
我的滚动视图代码:
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);
我的透明视图代码:
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];
非常感谢您的帮助:)
我真的不明白你在问什么。你需要在scrollview的底部有一个透明的视图,这样你可以在它上面滑动? – Martol1ni
种。我有一个全屏滚动视图,只能垂直滚动。现在想象一下,您只能在窗口底部实现向上滑动手势。因此,我在滚动视图上放置了一个透明视图来接收滑动手势,但它不会将正常的触摸事件转发给滚动视图 - 多数民众赞成在问题。 – christopher