Going through UIView to UIScrollView does not work

I have a view derived from a UIScrollView controller that I use to view images in a library. It works great.

I overlaid the UIView on the right side to handle the strokes to quickly scroll through the list of images. My problem is that if I pass strokes through "super" or "nextResponder", they never fall into the UIScrollView object below.

My question is: how can I get the UIScrollView below to process strokes that I don't need to process? I set the timer to 0.3 seconds, during which time all touches are transferred to the UIScrollView for processing. Therefore, if a user runs a gesture to turn the page, this will happen.

Here is the code for the touchBegan method:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];

// Start a timer to trigger the display of the slider and the processing of events.
touchesTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(showSlider:) userInfo:nil repeats:NO];

// Where are we at right now?
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
lastPage = [self page:currentPoint.y];

// Pass the event though until we need it.
//  [self.nextResponder touchesBegan:touches withEvent:event];
if ([touch.view isKindOfClass:[UIScrollView class]]) 
{
    if (self.nextResponder != nil &&
        [self.nextResponder respondsToSelector:@selector(touchesEnded:withEvent:)]) 
    {
        [self.nextResponder touchesEnded:touches withEvent:event];
    }
}
}
+3
2

UIViewController, UIScrollViewController, , , , . , , .

+1

, :

UIView UIScrollview 0 (, UIScrollView) clipToBounds = NO (, UIScrollView).

 self.OverlayView.clipsToBounds = NO;
 CGRect frame = self.OverlayView.frame;
 self.OverlayView.frame = CGRectMake(frame.origin.x, frame.origin.y, 0, 0);

, UIView , . UIScrollView.

0

Source: https://habr.com/ru/post/1705465/


All Articles