I encountered a problem during project development. I directly created a UIScrollerView ON THE UIViewController and added the UIScrollerView as a subview TO THE UIViewController,
Another UISlider component is added to UIScrollerView. During the gesture sliding process, it is difficult to slide to the UISlider control. During the Sliding Process, UIScrollerView is rolled,
The UISlider control does not slide, making people crazy.
I went to the Internet to learn more about UIScrollerView, and finally understood what the problem was.
The following is a summary of the predecessors, because I don't think his summary is detailed.
UIScrollView reloads the hitTest method. When you touch your finger, UIScrollView intercepts all events and waits for 150 ms. During this period, if no finger is moved, when the time ends, UIScrollView sends the tracking event to the subview without moving itself. When the finger moves before the end of the time, UIScrollView slides to cancel tracking.
It seems that this is a problem with UIScrollView. Drag the UISlider directly. When the touch time is within ms, UIScrollView considers it to be dragging itself, thus blocking the event. As a result, UISlider cannot accept the sliding event. However, if you press and hold UISlider for a while and then drag it again, the touch time exceeds 150 ms, so the sliding event will be sent to UISlider.
I tried several methods during this period. Only one method is feasible, namely to rewrite the hitTest method of UIScrollView: When sliding UISlider, The UIScrollView cannot be slide.
However, another problem occurs. My UIScrollerView inherits the UIScrollerView directly. In UIViewController, The UIScrollerView hitTest method cannot be rewritten. Therefore, you need to recreate a view to inherit the UIScrollerView, then rewrite the above method and import it to UIViewController.