简单继承UIApplication实现点击事件监听以及埋点
作者:
双轮自行车 | 来源:发表于
2019-02-21 15:27 被阅读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,从而进行拦截与埋点记录
本文标题:简单继承UIApplication实现点击事件监听以及埋点
本文链接:https://www.haomeiwen.com/subject/mmnryqtx.html
网友评论