当我想更改`UISlider`中的值时,scrollView向左滚动而不是滑块

时间:2016-06-14 11:30:54

标签: ios swift uicollectionview uislider uitapgesturerecognizer

我在UISlider滚动方向UICollectionViewhorizontal

当我想更改UISlider中的值时,scrollView会向左滚动而不是滑块!!

我尝试将UITapGestureRecognizer/UISwipeGestureRecognizer添加到滑块。

没有用。

1 个答案:

答案 0 :(得分:0)

现在它有效!我补充说:

override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {

    if !self.userInteractionEnabled || self.hidden || self.alpha <= 0.01 {
        return nil
    }

    for subview:UIView in self.subviews{
        let convertedPoint:CGPoint = subview.convertPoint(point, fromView: self)
        if let hitTestView: UIView = subview.hitTest(convertedPoint, withEvent: event) {
            if viewRating.frame.contains(point){
                delegate!.stopScrollCollectionView(true)
            }else{
                delegate!.stopScrollCollectionView(false)
            }
            return hitTestView
        }
    }
    return self
}