我有一个垂直滚动视图(不能水平滚动),默认情况下我的选项卡栏是隐藏的。然而,你可以通过在屏幕底部区域向上滑动来拉起标签栏。(内容需要很多垂直空间)这是我的两难境地:我希望能够在滚动视图的底部区域检测到向上滑动的手势,而不是滚动视图向下滚动。所以我想把一个透明的视图放在底部区域,以便只检测向上滑动。但这有一个问题,尽管该视图是透明的,但我所有的触摸事件都会被该视图截获,而不会被转发到滚动视图。
是否可以仅将点击转发到我的滚动视图,这样我仍然可以,例如,按下当前位于滚动视图底部区域的按钮?
奇怪的问题我知道,但我找不到一个类似的问题和一个有效的解决方案。
我的滚动视图代码:
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];非常感谢您的帮助:)
发布于 2013-05-26 18:54:53
也许你可以使用触摸的坐标(0,480)来追踪View bottom?
发布于 2013-12-06 06:56:48
您是否尝试过将底部UIView的userInteractionEnabled属性设置为NO?它应该仍然允许你的卷帘识别器工作,但是它应该阻止视图吞噬正常的触摸。
https://stackoverflow.com/questions/12873247
复制相似问题