https://github.com/zhipingyang/forgesturetrackdisplay
FORGestureTrackDisplay is debug tool to displaying and tracking all kinds of gustures when user touch the screen.
https://github.com/zhipingyang/forgesturetrackdisplay
guesture track
Last synced: 10 months ago
JSON representation
FORGestureTrackDisplay is debug tool to displaying and tracking all kinds of gustures when user touch the screen.
- Host: GitHub
- URL: https://github.com/zhipingyang/forgesturetrackdisplay
- Owner: ZhipingYang
- License: mit
- Created: 2017-05-31T15:07:10.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-01T02:16:37.000Z (about 9 years ago)
- Last Synced: 2025-08-16T22:34:41.287Z (10 months ago)
- Topics: guesture, track
- Language: Objective-C
- Homepage:
- Size: 31.3 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FORGestureTrackDisplay
> FORGestureTrackDisplay is debug tool to displaying and tracking all kinds of gustures when user touch the screen.

## Usage
**first method ( Manual )**
> in this way, just the appdelegate.window can track gustures.
```objective-c
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window startTracking];
return YES;
}
```
**second method ( auto )**
> I highly recommend this way for auto track gestures in all windows.
```objective-c
@implementation NSObject (Runtime)
+ (void)swizzleInstanceMethodWithOriginSel:(SEL)oriSel swizzledSel:(SEL)swiSel {
Method originAddObserverMethod = class_getInstanceMethod(self, oriSel);
Method swizzledAddObserverMethod = class_getInstanceMethod(self, swiSel);
[self swizzleMethodWithOriginSel:oriSel oriMethod:originAddObserverMethod swizzledSel:swiSel swizzledMethod:swizzledAddObserverMethod class:self];
}
+ (void)swizzleMethodWithOriginSel:(SEL)oriSel
oriMethod:(Method)oriMethod
swizzledSel:(SEL)swizzledSel
swizzledMethod:(Method)swizzledMethod
class:(Class)cls {
BOOL didAddMethod = class_addMethod(cls, oriSel, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(cls, swizzledSel, method_getImplementation(oriMethod), method_getTypeEncoding(oriMethod));
} else {
method_exchangeImplementations(oriMethod, swizzledMethod);
}
}
@end
```
```objective-c
@implementation UIWindow (Runtime)
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self swizzleInstanceMethodWithOriginSel:@selector(becomeKeyWindow) swizzledSel:@selector(xy_becomeKeyWindow)];
[self swizzleInstanceMethodWithOriginSel:@selector(resignKeyWindow) swizzledSel:@selector(xy_resignKeyWindow)];
});
}
- (void)xy_becomeKeyWindow
{
[self xy_becomeKeyWindow];
[self startTracking];
}
- (void)xy_resignKeyWindow
{
[self xy_resignKeyWindow];
[self endTracking];
}
@end
```
## Installation
FORGestureTrackDisplay is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod "FORGestureTrackDisplay"
```
## Author
XcodeYang, xcodeyang@gmail.com
## License
FORGestureTrackDisplay is available under the MIT license. See the LICENSE file for more info.