add UITapGestureRecognizer review by hongmo
Showing
8 changed files
with
35 additions
and
117 deletions
@@ -46,9 +46,9 @@ | @@ -46,9 +46,9 @@ | ||
46 | B1475E671F7F37FC0066B514 /* NSURLConnection+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1475E661F7F37FC0066B514 /* NSURLConnection+AutoTrack.m */; }; | 46 | B1475E671F7F37FC0066B514 /* NSURLConnection+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1475E661F7F37FC0066B514 /* NSURLConnection+AutoTrack.m */; }; |
47 | B1475E6D1F7F38280066B514 /* NSURLSession+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1475E6C1F7F38280066B514 /* NSURLSession+AutoTrack.m */; }; | 47 | B1475E6D1F7F38280066B514 /* NSURLSession+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1475E6C1F7F38280066B514 /* NSURLSession+AutoTrack.m */; }; |
48 | B14C0C821F8DF22200D963F3 /* SDWebImageManager+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B14C0C811F8DF22200D963F3 /* SDWebImageManager+AutoTrack.m */; }; | 48 | B14C0C821F8DF22200D963F3 /* SDWebImageManager+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B14C0C811F8DF22200D963F3 /* SDWebImageManager+AutoTrack.m */; }; |
49 | + B14C0C991F8E2E9B00D963F3 /* UITapGestureRecognizer+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B14C0C981F8E2E9B00D963F3 /* UITapGestureRecognizer+AutoTrack.m */; }; | ||
49 | B17F61DB1F6678CD009D1606 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B17F61DA1F6678CD009D1606 /* UserNotifications.framework */; }; | 50 | B17F61DB1F6678CD009D1606 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B17F61DA1F6678CD009D1606 /* UserNotifications.framework */; }; |
50 | B1A393141F7B4E04009700D9 /* UIControl+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */; }; | 51 | B1A393141F7B4E04009700D9 /* UIControl+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */; }; |
51 | - B1A393171F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A393161F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m */; }; | ||
52 | B1A9387C1F6A8AF600D6582C /* NSString+ER_URL.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A9387B1F6A8AF600D6582C /* NSString+ER_URL.m */; }; | 52 | B1A9387C1F6A8AF600D6582C /* NSString+ER_URL.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A9387B1F6A8AF600D6582C /* NSString+ER_URL.m */; }; |
53 | B1B6C3A01F74AD3100627DF3 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = B1B6C3951F74AD3100627DF3 /* README.md */; }; | 53 | B1B6C3A01F74AD3100627DF3 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = B1B6C3951F74AD3100627DF3 /* README.md */; }; |
54 | B1B6C3A11F74AD3100627DF3 /* UIScrollView+YHExposure.m in Sources */ = {isa = PBXBuildFile; fileRef = B1B6C3991F74AD3100627DF3 /* UIScrollView+YHExposure.m */; }; | 54 | B1B6C3A11F74AD3100627DF3 /* UIScrollView+YHExposure.m in Sources */ = {isa = PBXBuildFile; fileRef = B1B6C3991F74AD3100627DF3 /* UIScrollView+YHExposure.m */; }; |
@@ -167,11 +167,11 @@ | @@ -167,11 +167,11 @@ | ||
167 | B1475E6C1F7F38280066B514 /* NSURLSession+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLSession+AutoTrack.m"; sourceTree = "<group>"; }; | 167 | B1475E6C1F7F38280066B514 /* NSURLSession+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLSession+AutoTrack.m"; sourceTree = "<group>"; }; |
168 | B14C0C801F8DF22200D963F3 /* SDWebImageManager+AutoTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SDWebImageManager+AutoTrack.h"; sourceTree = "<group>"; }; | 168 | B14C0C801F8DF22200D963F3 /* SDWebImageManager+AutoTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SDWebImageManager+AutoTrack.h"; sourceTree = "<group>"; }; |
169 | B14C0C811F8DF22200D963F3 /* SDWebImageManager+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SDWebImageManager+AutoTrack.m"; sourceTree = "<group>"; }; | 169 | B14C0C811F8DF22200D963F3 /* SDWebImageManager+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SDWebImageManager+AutoTrack.m"; sourceTree = "<group>"; }; |
170 | + B14C0C971F8E2E9B00D963F3 /* UITapGestureRecognizer+AutoTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITapGestureRecognizer+AutoTrack.h"; sourceTree = "<group>"; }; | ||
171 | + B14C0C981F8E2E9B00D963F3 /* UITapGestureRecognizer+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITapGestureRecognizer+AutoTrack.m"; sourceTree = "<group>"; }; | ||
170 | B17F61DA1F6678CD009D1606 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; }; | 172 | B17F61DA1F6678CD009D1606 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; }; |
171 | B1A393121F7B4E04009700D9 /* UIControl+AutoTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIControl+AutoTrack.h"; sourceTree = "<group>"; }; | 173 | B1A393121F7B4E04009700D9 /* UIControl+AutoTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIControl+AutoTrack.h"; sourceTree = "<group>"; }; |
172 | B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIControl+AutoTrack.m"; sourceTree = "<group>"; }; | 174 | B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIControl+AutoTrack.m"; sourceTree = "<group>"; }; |
173 | - B1A393151F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIGestureRecognizer+AutoTrack.h"; sourceTree = "<group>"; }; | ||
174 | - B1A393161F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIGestureRecognizer+AutoTrack.m"; sourceTree = "<group>"; }; | ||
175 | B1A9387A1F6A8AF600D6582C /* NSString+ER_URL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+ER_URL.h"; sourceTree = "<group>"; }; | 175 | B1A9387A1F6A8AF600D6582C /* NSString+ER_URL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+ER_URL.h"; sourceTree = "<group>"; }; |
176 | B1A9387B1F6A8AF600D6582C /* NSString+ER_URL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+ER_URL.m"; sourceTree = "<group>"; }; | 176 | B1A9387B1F6A8AF600D6582C /* NSString+ER_URL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+ER_URL.m"; sourceTree = "<group>"; }; |
177 | B1B6C3951F74AD3100627DF3 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; }; | 177 | B1B6C3951F74AD3100627DF3 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; }; |
@@ -315,14 +315,14 @@ | @@ -315,14 +315,14 @@ | ||
315 | 29CDB4B01F6FA5A500AAD350 /* PowerfulBannerView+AutoTrack.m */, | 315 | 29CDB4B01F6FA5A500AAD350 /* PowerfulBannerView+AutoTrack.m */, |
316 | B1A393121F7B4E04009700D9 /* UIControl+AutoTrack.h */, | 316 | B1A393121F7B4E04009700D9 /* UIControl+AutoTrack.h */, |
317 | B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */, | 317 | B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */, |
318 | - B1A393151F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.h */, | ||
319 | - B1A393161F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m */, | ||
320 | B1475E651F7F37FC0066B514 /* NSURLConnection+AutoTrack.h */, | 318 | B1475E651F7F37FC0066B514 /* NSURLConnection+AutoTrack.h */, |
321 | B1475E661F7F37FC0066B514 /* NSURLConnection+AutoTrack.m */, | 319 | B1475E661F7F37FC0066B514 /* NSURLConnection+AutoTrack.m */, |
322 | B1475E6B1F7F38280066B514 /* NSURLSession+AutoTrack.h */, | 320 | B1475E6B1F7F38280066B514 /* NSURLSession+AutoTrack.h */, |
323 | B1475E6C1F7F38280066B514 /* NSURLSession+AutoTrack.m */, | 321 | B1475E6C1F7F38280066B514 /* NSURLSession+AutoTrack.m */, |
324 | B14C0C801F8DF22200D963F3 /* SDWebImageManager+AutoTrack.h */, | 322 | B14C0C801F8DF22200D963F3 /* SDWebImageManager+AutoTrack.h */, |
325 | B14C0C811F8DF22200D963F3 /* SDWebImageManager+AutoTrack.m */, | 323 | B14C0C811F8DF22200D963F3 /* SDWebImageManager+AutoTrack.m */, |
324 | + B14C0C971F8E2E9B00D963F3 /* UITapGestureRecognizer+AutoTrack.h */, | ||
325 | + B14C0C981F8E2E9B00D963F3 /* UITapGestureRecognizer+AutoTrack.m */, | ||
326 | ); | 326 | ); |
327 | path = YH_AOP; | 327 | path = YH_AOP; |
328 | sourceTree = "<group>"; | 328 | sourceTree = "<group>"; |
@@ -705,6 +705,7 @@ | @@ -705,6 +705,7 @@ | ||
705 | 5255C2BB1F5D25F400A8FC5F /* YHSwizzle.m in Sources */, | 705 | 5255C2BB1F5D25F400A8FC5F /* YHSwizzle.m in Sources */, |
706 | 52D204EE1F61360200CB7F1A /* UIActionSheet+AutoTrack.m in Sources */, | 706 | 52D204EE1F61360200CB7F1A /* UIActionSheet+AutoTrack.m in Sources */, |
707 | B1D774AE1F62A37E00BA89C3 /* UIImageView+HighlightedWebCache.m in Sources */, | 707 | B1D774AE1F62A37E00BA89C3 /* UIImageView+HighlightedWebCache.m in Sources */, |
708 | + B14C0C991F8E2E9B00D963F3 /* UITapGestureRecognizer+AutoTrack.m in Sources */, | ||
708 | B1D774A91F62A37E00BA89C3 /* SDWebImagePrefetcher.m in Sources */, | 709 | B1D774A91F62A37E00BA89C3 /* SDWebImagePrefetcher.m in Sources */, |
709 | 29D3B9791F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m in Sources */, | 710 | 29D3B9791F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m in Sources */, |
710 | B1D774A71F62A37E00BA89C3 /* SDWebImageDownloaderOperation.m in Sources */, | 711 | B1D774A71F62A37E00BA89C3 /* SDWebImageDownloaderOperation.m in Sources */, |
@@ -735,7 +736,6 @@ | @@ -735,7 +736,6 @@ | ||
735 | 5255C2C11F5D25F400A8FC5F /* YHEventReport.m in Sources */, | 736 | 5255C2C11F5D25F400A8FC5F /* YHEventReport.m in Sources */, |
736 | 529A004B1F564E8500A83F63 /* main.m in Sources */, | 737 | 529A004B1F564E8500A83F63 /* main.m in Sources */, |
737 | B1C419021F616187005E0729 /* OpenUDID.m in Sources */, | 738 | B1C419021F616187005E0729 /* OpenUDID.m in Sources */, |
738 | - B1A393171F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m in Sources */, | ||
739 | B1D774A51F62A37E00BA89C3 /* SDWebImageDownloader.m in Sources */, | 739 | B1D774A51F62A37E00BA89C3 /* SDWebImageDownloader.m in Sources */, |
740 | 52878C0D1F5FEE4C000A1597 /* YH_EventDataFactory.m in Sources */, | 740 | 52878C0D1F5FEE4C000A1597 /* YH_EventDataFactory.m in Sources */, |
741 | B1D774AC1F62A37E00BA89C3 /* UIImage+MultiFormat.m in Sources */, | 741 | B1D774AC1F62A37E00BA89C3 /* UIImage+MultiFormat.m in Sources */, |
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | #import "UIViewController+AutoTrack.h" | 20 | #import "UIViewController+AutoTrack.h" |
21 | #import "UITabBar+AutoTrack.h" | 21 | #import "UITabBar+AutoTrack.h" |
22 | #import "UIControl+AutoTrack.h" | 22 | #import "UIControl+AutoTrack.h" |
23 | -#import "UIGestureRecognizer+AutoTrack.h" | 23 | +#import "UITapGestureRecognizer+AutoTrack.h" |
24 | #import "NSURLConnection+AutoTrack.h" | 24 | #import "NSURLConnection+AutoTrack.h" |
25 | 25 | ||
26 | #define kYHEventReportIgnoredViewController @"YHEventReportQueue" | 26 | #define kYHEventReportIgnoredViewController @"YHEventReportQueue" |
@@ -149,7 +149,7 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; | @@ -149,7 +149,7 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; | ||
149 | [UIViewController startTrack]; | 149 | [UIViewController startTrack]; |
150 | [UITabBar startTrack]; | 150 | [UITabBar startTrack]; |
151 | [UIControl startTrack]; | 151 | [UIControl startTrack]; |
152 | - [UIGestureRecognizer startTrack]; | 152 | + [UITapGestureRecognizer startTrack]; |
153 | [NSURLConnection startTrack]; | 153 | [NSURLConnection startTrack]; |
154 | 154 | ||
155 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | 155 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
1 | // | 1 | // |
2 | -// UIGestureRecognizer+AutoTrack.h | 2 | +// UITapGestureRecognizer+AutoTrack.h |
3 | // YHEventReport | 3 | // YHEventReport |
4 | // | 4 | // |
5 | -// Created by 孙凯 on 2017/9/28. | 5 | +// Created by 孙凯 on 2017/10/11. |
6 | // Copyright © 2017年 YOHO. All rights reserved. | 6 | // Copyright © 2017年 YOHO. All rights reserved. |
7 | // | 7 | // |
8 | 8 | ||
9 | #import <UIKit/UIKit.h> | 9 | #import <UIKit/UIKit.h> |
10 | 10 | ||
11 | -@interface UIGestureRecognizer (AutoTrack) | 11 | +@interface UITapGestureRecognizer (AutoTrack) |
12 | 12 | ||
13 | @property(nonatomic,copy)NSString *yh_viewId;//唯一ID | 13 | @property(nonatomic,copy)NSString *yh_viewId;//唯一ID |
14 | 14 |
1 | // | 1 | // |
2 | -// UIGestureRecognizer+AutoTrack.m | 2 | +// UITapGestureRecognizer+AutoTrack.m |
3 | // YHEventReport | 3 | // YHEventReport |
4 | // | 4 | // |
5 | -// Created by 孙凯 on 2017/9/28. | 5 | +// Created by 孙凯 on 2017/10/11. |
6 | // Copyright © 2017年 YOHO. All rights reserved. | 6 | // Copyright © 2017年 YOHO. All rights reserved. |
7 | // | 7 | // |
8 | 8 | ||
9 | -#import "UIGestureRecognizer+AutoTrack.h" | 9 | +#import "UITapGestureRecognizer+AutoTrack.h" |
10 | #import "YHSwizzle.h" | 10 | #import "YHSwizzle.h" |
11 | #import <objc/runtime.h> | 11 | #import <objc/runtime.h> |
12 | #import <objc/message.h> | 12 | #import <objc/message.h> |
@@ -14,13 +14,7 @@ | @@ -14,13 +14,7 @@ | ||
14 | #import "YHEventReport.h" | 14 | #import "YHEventReport.h" |
15 | #import "YH_EventCollector.h" | 15 | #import "YH_EventCollector.h" |
16 | 16 | ||
17 | -@interface UIGestureRecognizer ()<UIGestureRecognizerDelegate> | ||
18 | - | ||
19 | -@property(nullable,nonatomic,weak) id <UIGestureRecognizerDelegate> my_delegate; | ||
20 | - | ||
21 | -@end | ||
22 | - | ||
23 | -@implementation UIGestureRecognizer (AutoTrack) | 17 | +@implementation UITapGestureRecognizer (AutoTrack) |
24 | 18 | ||
25 | #pragma mark - 属性 | 19 | #pragma mark - 属性 |
26 | - (void)setYh_viewId:(NSString *)yh_viewId{ | 20 | - (void)setYh_viewId:(NSString *)yh_viewId{ |
@@ -31,16 +25,6 @@ | @@ -31,16 +25,6 @@ | ||
31 | return objc_getAssociatedObject(self, @selector(yh_viewId)); | 25 | return objc_getAssociatedObject(self, @selector(yh_viewId)); |
32 | } | 26 | } |
33 | 27 | ||
34 | -- (id)my_delegate | ||
35 | -{ | ||
36 | - return objc_getAssociatedObject(self, _cmd); | ||
37 | -} | ||
38 | - | ||
39 | -- (void)setMy_delegate:(id)my_delegate | ||
40 | -{ | ||
41 | - objc_setAssociatedObject(self, @selector(my_delegate), my_delegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
42 | -} | ||
43 | - | ||
44 | #pragma mark - load | 28 | #pragma mark - load |
45 | + (void)startTrack{ | 29 | + (void)startTrack{ |
46 | static dispatch_once_t onceToken; | 30 | static dispatch_once_t onceToken; |
@@ -49,7 +33,6 @@ | @@ -49,7 +33,6 @@ | ||
49 | SEL selectors[] = { | 33 | SEL selectors[] = { |
50 | @selector(initWithTarget:action:), | 34 | @selector(initWithTarget:action:), |
51 | @selector(addTarget:action:), | 35 | @selector(addTarget:action:), |
52 | - @selector(setDelegate:), | ||
53 | }; | 36 | }; |
54 | 37 | ||
55 | for (NSUInteger index = 0; index < sizeof(selectors) / sizeof(SEL); ++index) { | 38 | for (NSUInteger index = 0; index < sizeof(selectors) / sizeof(SEL); ++index) { |
@@ -71,23 +54,10 @@ | @@ -71,23 +54,10 @@ | ||
71 | } | 54 | } |
72 | 55 | ||
73 | #pragma mark - hook API | 56 | #pragma mark - hook API |
74 | --(void)yher_setDelegate:(id<UIGestureRecognizerDelegate>)delegate | ||
75 | -{ | ||
76 | - if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].buttonPerformanceTrackEnable && ([delegate isKindOfClass:[UIViewController class]] || [delegate isKindOfClass:[UIImageView class]] || [delegate isKindOfClass:[UILabel class]])) { | ||
77 | - if (![delegate isKindOfClass:[self class]]) { | ||
78 | - [self setMy_delegate:delegate]; | ||
79 | - return; | ||
80 | - } | ||
81 | - } | ||
82 | - [self yher_setDelegate:delegate]; | ||
83 | - | ||
84 | -} | ||
85 | - | ||
86 | - (instancetype)yher_initWithTarget:(nullable id)target action:(nullable SEL)action | 57 | - (instancetype)yher_initWithTarget:(nullable id)target action:(nullable SEL)action |
87 | { | 58 | { |
88 | - if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].buttonPerformanceTrackEnable && ([target isKindOfClass:[UIViewController class]] || [target isKindOfClass:[UIImageView class]] || [target isKindOfClass:[UILabel class]])) { | ||
89 | - [UIGestureRecognizer yher_exchangeSelector:action target:target toSelector:@selector(yher_gestureRecognizerDidTouch_cmd:)]; | ||
90 | - [self setDelegate:self]; | 59 | + if (([target isKindOfClass:[UIViewController class]] || [target isKindOfClass:[UIImageView class]] || [target isKindOfClass:[UILabel class]])) { |
60 | + [UITapGestureRecognizer yher_exchangeSelector:action target:target toSelector:@selector(yher_gestureRecognizerDidTouch_cmd:)]; | ||
91 | } | 61 | } |
92 | return [self yher_initWithTarget:target action:action]; | 62 | return [self yher_initWithTarget:target action:action]; |
93 | } | 63 | } |
@@ -95,22 +65,26 @@ | @@ -95,22 +65,26 @@ | ||
95 | - (void)yher_addTarget:(id)target action:(SEL)action | 65 | - (void)yher_addTarget:(id)target action:(SEL)action |
96 | { | 66 | { |
97 | if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].buttonPerformanceTrackEnable && ([target isKindOfClass:[UIViewController class]] || [target isKindOfClass:[UIImageView class]] || [target isKindOfClass:[UILabel class]])) { | 67 | if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].buttonPerformanceTrackEnable && ([target isKindOfClass:[UIViewController class]] || [target isKindOfClass:[UIImageView class]] || [target isKindOfClass:[UILabel class]])) { |
98 | - [UIGestureRecognizer yher_exchangeSelector:action target:target toSelector:@selector(yher_gestureRecognizerDidTouch_cmd:)]; | ||
99 | - [self setDelegate:self]; | 68 | + [UITapGestureRecognizer yher_exchangeSelector:action target:target toSelector:@selector(yher_gestureRecognizerDidTouch_cmd:)]; |
100 | } | 69 | } |
101 | - | 70 | + |
102 | [self yher_addTarget:target action:action]; | 71 | [self yher_addTarget:target action:action]; |
103 | } | 72 | } |
104 | 73 | ||
105 | #pragma mark - action | 74 | #pragma mark - action |
106 | - (void)yher_gestureRecognizerDidTouch_cmd:(UIGestureRecognizer*)sender | 75 | - (void)yher_gestureRecognizerDidTouch_cmd:(UIGestureRecognizer*)sender |
107 | { | 76 | { |
108 | - | ||
109 | - if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].buttonPerformanceTrackEnable && ([sender.view isKindOfClass:[UIImageView class]] || [sender.view isKindOfClass:[UILabel class]])) { | ||
110 | - [[YH_EventCollector sharedInstance] timeEventEndWithUIGestureRecognizer:sender]; | 77 | + if (([sender.view isKindOfClass:[UIImageView class]] || [sender.view isKindOfClass:[UILabel class]])) { |
78 | + [[YH_EventCollector sharedInstance] timeEventStartWithUIGestureRecognizer:sender]; | ||
111 | } | 79 | } |
112 | 80 | ||
81 | + | ||
113 | [self yher_gestureRecognizerDidTouch_cmd:sender]; | 82 | [self yher_gestureRecognizerDidTouch_cmd:sender]; |
83 | + | ||
84 | + | ||
85 | + if (([sender.view isKindOfClass:[UIImageView class]] || [sender.view isKindOfClass:[UILabel class]])) { | ||
86 | + [[YH_EventCollector sharedInstance] timeEventEndWithUIGestureRecognizer:sender]; | ||
87 | + } | ||
114 | } | 88 | } |
115 | 89 | ||
116 | #pragma mark - hook func | 90 | #pragma mark - hook func |
@@ -132,60 +106,4 @@ | @@ -132,60 +106,4 @@ | ||
132 | class_replaceMethod(originalClass,originalSelector,swizzledIMP,swizzledType); | 106 | class_replaceMethod(originalClass,originalSelector,swizzledIMP,swizzledType); |
133 | } | 107 | } |
134 | 108 | ||
135 | -#pragma mark - UIGestureRecognizerDelegate | ||
136 | -- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer | ||
137 | -{ | ||
138 | - if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].buttonPerformanceTrackEnable) { | ||
139 | - [[YH_EventCollector sharedInstance] timeEventStartWithUIGestureRecognizer:self]; | ||
140 | - } | ||
141 | - | ||
142 | - if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizerShouldBegin:)]) { | ||
143 | - return [self.my_delegate gestureRecognizerShouldBegin:gestureRecognizer]; | ||
144 | - } | ||
145 | - return YES; | ||
146 | -} | ||
147 | - | ||
148 | - | ||
149 | -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer | ||
150 | -{ | ||
151 | - if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:)]) { | ||
152 | - return [self.my_delegate gestureRecognizer:gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer]; | ||
153 | - } | ||
154 | - | ||
155 | - return YES; | ||
156 | -} | ||
157 | - | ||
158 | -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer | ||
159 | -{ | ||
160 | - if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:)]) { | ||
161 | - return [self.my_delegate gestureRecognizer:gestureRecognizer shouldRequireFailureOfGestureRecognizer:otherGestureRecognizer]; | ||
162 | - } | ||
163 | - return YES; | ||
164 | -} | ||
165 | - | ||
166 | -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer | ||
167 | -{ | ||
168 | - if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:)]) { | ||
169 | - return [self.my_delegate gestureRecognizer:gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:otherGestureRecognizer]; | ||
170 | - } | ||
171 | - return YES; | ||
172 | -} | ||
173 | - | ||
174 | -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch | ||
175 | -{ | ||
176 | - if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldReceiveTouch:)]) { | ||
177 | - return [self.my_delegate gestureRecognizer:gestureRecognizer shouldReceiveTouch:touch]; | ||
178 | - } | ||
179 | - return YES; | ||
180 | -} | ||
181 | - | ||
182 | -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceivePress:(UIPress *)press | ||
183 | -{ | ||
184 | - if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldReceivePress:)]) { | ||
185 | - return [self.my_delegate gestureRecognizer:gestureRecognizer shouldReceivePress:press]; | ||
186 | - } | ||
187 | - return YES; | ||
188 | -} | ||
189 | - | ||
190 | - | ||
191 | @end | 109 | @end |
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | #import "UIWebView+AutoTrack.h" | 18 | #import "UIWebView+AutoTrack.h" |
19 | #import "UITabBarItem+Yoho.h" | 19 | #import "UITabBarItem+Yoho.h" |
20 | #import "UIControl+AutoTrack.h" | 20 | #import "UIControl+AutoTrack.h" |
21 | -#import "UIGestureRecognizer+AutoTrack.h" | 21 | +#import "UITapGestureRecognizer+AutoTrack.h" |
22 | 22 | ||
23 | #define kYHEventReportQueue @"YHEventReportQueue" | 23 | #define kYHEventReportQueue @"YHEventReportQueue" |
24 | #define kYHEventReporrH5StartKey @"YHEventReporrH5StartKey" | 24 | #define kYHEventReporrH5StartKey @"YHEventReporrH5StartKey" |
@@ -349,8 +349,8 @@ | @@ -349,8 +349,8 @@ | ||
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | -#pragma mark - UIGestureRecognizer performance | ||
353 | -- (void)timeEventStartWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer | 352 | +#pragma mark - UITapGestureRecognizer performance |
353 | +- (void)timeEventStartWithUIGestureRecognizer:(UITapGestureRecognizer *)gestureRecognizer | ||
354 | { | 354 | { |
355 | NSNumber *startTime = @([[NSDate date] timeIntervalSince1970]); | 355 | NSNumber *startTime = @([[NSDate date] timeIntervalSince1970]); |
356 | NSString *viewId = [NSString stringWithFormat:@"%@%@",NSStringFromClass([gestureRecognizer class]),startTime]; | 356 | NSString *viewId = [NSString stringWithFormat:@"%@%@",NSStringFromClass([gestureRecognizer class]),startTime]; |
@@ -370,7 +370,7 @@ | @@ -370,7 +370,7 @@ | ||
370 | }); | 370 | }); |
371 | } | 371 | } |
372 | 372 | ||
373 | -- (void)timeEventEndWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer | 373 | +- (void)timeEventEndWithUIGestureRecognizer:(UITapGestureRecognizer *)gestureRecognizer |
374 | { | 374 | { |
375 | NSTimeInterval elapsedTime = [self eventElapsedTime:gestureRecognizer.yh_viewId]; | 375 | NSTimeInterval elapsedTime = [self eventElapsedTime:gestureRecognizer.yh_viewId]; |
376 | 376 | ||
@@ -386,7 +386,7 @@ | @@ -386,7 +386,7 @@ | ||
386 | 386 | ||
387 | NSDictionary *param = [YH_EventDataFactory factoryTimeEventDataWithUIGestureRecognizer:gestureRecognizer ElapsedTime:elapsedTime]; | 387 | NSDictionary *param = [YH_EventDataFactory factoryTimeEventDataWithUIGestureRecognizer:gestureRecognizer ElapsedTime:elapsedTime]; |
388 | 388 | ||
389 | - //NSLog(@"%@",param); | 389 | + NSLog(@"%@",param); |
390 | if (param) { | 390 | if (param) { |
391 | [[YH_EventCacheManager sharedInstance] pushPerformanceData:param pointName:YHPN_GESTURERECOGNIZER]; | 391 | [[YH_EventCacheManager sharedInstance] pushPerformanceData:param pointName:YHPN_GESTURERECOGNIZER]; |
392 | } | 392 | } |
@@ -91,7 +91,7 @@ typedef NS_ENUM(NSInteger, YHEventReportPointName) { | @@ -91,7 +91,7 @@ typedef NS_ENUM(NSInteger, YHEventReportPointName) { | ||
91 | YHPN_WEBVIEW,//UIWebView 加载时间 // @"WEBVIEW" | 91 | YHPN_WEBVIEW,//UIWebView 加载时间 // @"WEBVIEW" |
92 | YHPN_IMAGEVIEW,//Image (SDWebImage) 加载时间 // @"IMAGE" | 92 | YHPN_IMAGEVIEW,//Image (SDWebImage) 加载时间 // @"IMAGE" |
93 | YHPN_BUTTON,//Button 响应时间 // @"BUTTON" | 93 | YHPN_BUTTON,//Button 响应时间 // @"BUTTON" |
94 | - YHPN_GESTURERECOGNIZER //UIGestureRecognizer响应时间// @"GESTURERECOGNIZER" | 94 | + YHPN_GESTURERECOGNIZER //UITapGestureRecognizer响应时间// @"GESTURERECOGNIZER" |
95 | }; | 95 | }; |
96 | 96 | ||
97 | typedef NS_ENUM(NSInteger, YHEventReportType) { | 97 | typedef NS_ENUM(NSInteger, YHEventReportType) { |
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | 21 | ||
22 | +(NSDictionary *)factoryTimeEventDataWithUIControl:(UIControl *)control ElapsedTime:(NSTimeInterval)elapsedTime; | 22 | +(NSDictionary *)factoryTimeEventDataWithUIControl:(UIControl *)control ElapsedTime:(NSTimeInterval)elapsedTime; |
23 | 23 | ||
24 | -+(NSDictionary *)factoryTimeEventDataWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer ElapsedTime:(NSTimeInterval)elapsedTime; | 24 | ++(NSDictionary *)factoryTimeEventDataWithUIGestureRecognizer:(UITapGestureRecognizer *)gestureRecognizer ElapsedTime:(NSTimeInterval)elapsedTime; |
25 | 25 | ||
26 | + (NSDictionary *)factoryEventAppInfo:(YH_PerformanceAppInfo*)appInfo; | 26 | + (NSDictionary *)factoryEventAppInfo:(YH_PerformanceAppInfo*)appInfo; |
27 | 27 |
@@ -66,7 +66,7 @@ | @@ -66,7 +66,7 @@ | ||
66 | return dict; | 66 | return dict; |
67 | } | 67 | } |
68 | 68 | ||
69 | -+(NSDictionary *)factoryTimeEventDataWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer ElapsedTime:(NSTimeInterval)elapsedTime { | 69 | ++(NSDictionary *)factoryTimeEventDataWithUIGestureRecognizer:(UITapGestureRecognizer *)gestureRecognizer ElapsedTime:(NSTimeInterval)elapsedTime { |
70 | 70 | ||
71 | NSString *className = NSStringFromClass([gestureRecognizer class]); | 71 | NSString *className = NSStringFromClass([gestureRecognizer class]); |
72 | 72 |
-
Please register or login to post a comment