美文网首页
growingio与自定义的uicontrol 分类 hook冲

growingio与自定义的uicontrol 分类 hook冲

作者: 可爱的33 | 来源:发表于2018-01-26 14:32 被阅读58次

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

}

相关文章

网友评论

      本文标题:growingio与自定义的uicontrol 分类 hook冲

      本文链接:https://www.haomeiwen.com/subject/ratwaxtx.html