student swift student swift - 5 months ago 38
Swift Question

UISlider in UICollectionView Horizontal - Conflict - iOS swift

I have

UISlider
in
UICollectionView
scroll direction
horizontal
.

When I want to change the value in the
UISlider
, the scrollView scrolls left instead of the slider!!

I tried to add
UITapGestureRecognizer/UISwipeGestureRecognizer
to the slider.

It did not help.

Answer

Now it works! I added:

override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
    for subview:UIView in self.subviews{
        let insideSubview:CGPoint = self.convertPoint(point, toView: subview)
        if let sview: UIView = subview.hitTest(insideSubview, withEvent: event) {
            if viewRating.frame.contains(point){
                  delegate!.stopScrollCollectionView(true)
            }else{
                delegate!.stopScrollCollectionView(false)
            }
            return sview
        }
    }
    return self
}