growingio与自定义的uicontrol 分类 hook冲

2018-01-26  本文已影响58人  可爱的33

// 在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];

}

上一篇 下一篇

猜你喜欢

热点阅读