UISlider and UIScrollView

后端 未结 7 1821
猫巷女王i
猫巷女王i 2020-12-13 01:11

I have a UISlider as part of a view that is loaded into a UIScrollView with paging enabled. I\'ve noticed an unexpected behavior. If the user tries

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 01:52

    While creating an audio player I had the exact problem with a sliderView and it is added to a scrollView , and whenever I touched the sliderView , the scrollView used to get the touch and instead of the sliderView , the scrollView moved . To avoid this , I disabled the srcolling of the scrollView when the user touched the sliderView and otherwise the scrolling is enabled .

    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    
        UIView *result = [super hitTest:point withEvent:event] ;
        if (result == sliderView)
        {
            scrollView.scrollEnabled = NO ;
        }
        else
        {
            scrollView.scrollEnabled = YES ;
        }
    
        return result ;
    
    }
    

提交回复
热议问题