ICViewPager拦截来自我的uislider的触摸事件

时间:2015-09-09 17:08:19

标签: ios uislider

我已经使用ICViewPager作为带标签的滚动视图。当我在视图中放置滑块时,用户必须先按下滚动旋钮一秒钟才能移动它,否则整个页面会随滑块移动。

我试过了:

  • 将滑块设置为exclusiveTouch。

  • 创建滑块控制器并将触摸事件直接发送到滑块

    -(CGRect)thumbRect
    {
    CGRect trackRect = [self trackRectForBounds:self.bounds];
    CGRect thumbRect = [self thumbRectForBounds:self.bounds
                                      trackRect:trackRect
                                          value:self.value];
    return thumbRect;
    
    }
    
    -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    {
    CGRect thumbFrame = [self thumbRect];
    
    // check if the point is within the thumb
    if (CGRectContainsPoint(thumbFrame, point))
    {
        // if so trigger the method of the super class
        NSLog(@"inside thumb");
        return [super hitTest:point withEvent:event];
    }
    else
    {
        // if not just pass the event on to your superview
        NSLog(@"outside thumb");
        return [[self superview] hitTest:point withEvent:event];
    }
    }
    

1 个答案:

答案 0 :(得分:0)

有同样的问题。我通过使用自定义滑块找到了一种解决方法,并使用了UIGestureRecognizer而不是touchesBegan,touchesEnded函数

相关问题