Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>there's no need for a hit test on the <code>UIScrollView</code> side. since the delay is set by the <code>UIScrollView</code> itself. subclassing and implementing a custom <code>hitTest:withEvent:</code> won't help since it's still triggered with delay.</p> <p>i searched hours for an elegant solution to this, since i wanted to simulate apple's own volumeslider in the ios application switcher. </p> <p>the trick: </p> <pre><code>yourScrollView.delaysContentTouches = NO; </code></pre> <p>unfortunately this disables events along the <code>UISliders</code> track, so for this part your <code>UIScrollView</code> won't trigger any touchevents because they are caught by the slider first. </p> <p>to pass touchevents other than those which are in the <code>UISliders</code> thumb rect you have to subclass <code>UISlider</code> and add the following:</p> <pre><code>// get the location of the thumb - (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]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload