Is there any way to get every responder that processed UITouch?

I'm trying to debug some Began / Moved / Ended touches related to slowdown in my game; I think that some of my response participants are not unloaded properly, and as the game works more and more, they add up and touches become less responsive because they have to go through a large and large chain of respondents.

Is there any way to view / get the path received by UITouch when it moves along the chain? Or just somehow get a list of all active respondents?

Thanks, -S

+3
source share
2 answers

UIResponder, , . :

#import <objc/runtime.h>

@interface UIResponder (MYHijack)
+ (void)hijack;
@end

@implementation UIResponder (MYHijack)
+ (void)hijackSelector:(SEL)originalSelector withSelector:(SEL)newSelector
{
    Class class = [UIResponder class];
    Method originalMethod = class_getInstanceMethod(class, originalSelector);
    Method categoryMethod = class_getInstanceMethod(class, newSelector);
    method_exchangeImplementations(originalMethod, categoryMethod);
}

+ (void)hijack
{
    [self hijackSelector:@selector(touchesBegan:withEvent:) withSelector:@selector(MYHijack_touchesBegan:withEvent:)];
}

- (void)MYHijack_touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touches!");
    [self MYHijack_touchesBegan:touches withEvent:event]; // Calls the original version of this method
}
@end

- ( main()), [UIResponder hijack]. UIResponder super - , .

method_exchangeImplementations() - . , ; , , .

+5
+1

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


All Articles