Does TouchsMoved no longer start after changing UIView to UIScrollView?

I had a UIView with lots of objects. I also had an implementation of touchsMoved like this:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"move");
}

I recently wanted to scroll the view, so I just opened UIView, and in Interface Builder I changed my object class to UIScrollView. However, now the "touchhesMoved" method is never called even when you touch the screen.

Can someone please help me get touchhesMoved to work again? I'm not sure what I did to break it!

EDIT: I tried following this guide , but I might have done something wrong. From reading other posts, it seems that UIScrollView cannot receive touch events itself, and they need to send a chain of responders? I will be extremely grateful to anyone who can help me in solving this problem ... my application was ready for presentation when I realized that UIScrolView killed my touch detection! (I just changed my UIView apps to UIScrollView to be compatible with iPhone 4).

+1
source share
1 answer

, , . . .

UIScrollView :

#import "AppScrollView.h"

@implementation AppScrollView

- (id)initWithFrame:(CGRect)frame
{
    return [super initWithFrame:frame];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"AppScrollView touchesEnded:withEvent:");

    // If not dragging, send event to next responder
    if (!self.dragging)
        [[self.nextResponder nextResponder] touchesEnded:touches withEvent:event];
    else
        [super touchesEnded: touches withEvent: event];

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"AppScrollView touchesMoved:withEvent:");

    [[self.nextResponder nextResponder] touchesMoved:touches withEvent:event];
}

@end

, AppScrollView, UIScrollViewDelegate :

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"SomeClass touchesMoved:withEvent:");
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"SomeClass touchesEnded:withEvent:");
}

:

2013-06-11 10:45:21.625 Test[54090:c07] AppScrollView touchesMoved:withEvent:
2013-06-11 10:45:21.625 Test[54090:c07] SomeClass touchesMoved:withEvent:
2013-06-11 10:45:21.642 Test[54090:c07] AppScrollView touchesMoved:withEvent:
2013-06-11 10:45:21.642 Test[54090:c07] SomeClass touchesMoved:withEvent:
2013-06-11 10:45:21.655 Test[54090:c07] AppScrollView touchesEnded:withEvent:
2013-06-11 10:45:21.656 Test[54090:c07] SomeClass touchesEnded:withEvent:
+3

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


All Articles