简单继承UIApplication实现点击事件监听以及埋点

2019-02-21  本文已影响0人  双轮自行车

1.创建MyApplication继承UIApplication

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface MyApplication : UIApplication

@end

NS_ASSUME_NONNULL_END

2.(重要)在main.m中添加我们的类

avatar

3.在MyApplication.m中实现监听点击的方法

- (BOOL)sendAction:(SEL)action to:(nullable id)target from:(nullable id)sender forEvent:(nullable UIEvent *)event{
    NSLog(@"进这里");
    [super sendAction:action to:target from:sender forEvent:event];
    return YES;
}

- (void)sendEvent:(UIEvent *)event{

    [super sendEvent:event];
}

4.在sendAction方法里判断点击事件和View,从而进行拦截与埋点记录

上一篇下一篇

猜你喜欢

热点阅读