// 在load时执行hook
+ (void)load {
Methodbefore =class_getInstanceMethod(self,@selector(sendAction:to:forEvent:));
Methodafter =class_getInstanceMethod(self,@selector(cs_sendAction:to:forEvent:));
method_exchangeImplementations(before, after);
}
- (void)cs_sendAction:(SEL)action to:(id)target forEvent:(UIEvent*)event {
if (![NSStringFromSelector(action) hasPrefix:@"growingHook"]) {
if ([NSDate date].timeIntervalSince1970 - self.cs_acceptEventTime < self.cs_acceptEventInterval) {
return;
}
if (self.cs_acceptEventInterval > 0) {
self.cs_acceptEventTime = [NSDate date].timeIntervalSince1970;
}
}
[selfcs_sendAction:actionto:targetforEvent:event];
}