Latest 0.1.0
Homepage https://github.com/ZhipingYang/FORGestureTrackDisplay
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

FORGestureTrackDisplay is debug tool to displaying and tracking all kinds of gustures when user touch the screen.

untitled

Usage

first method ( Manual )

in this way, just the appdelegate.window can track gustures.

- (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.

@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
@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. To install
it, simply add the following line to your Podfile:

pod "FORGestureTrackDisplay"

Author

XcodeYang, [email protected]

License

FORGestureTrackDisplay is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "FORGestureTrackDisplay",
    "summary": "Tracking the gustures and displaying in window",
    "description": "FORGestureTrackDisplay is debug tool to displaying and tracking all kinds of gustures when user touch the screen.",
    "version": "0.1.0",
    "homepage": "https://github.com/ZhipingYang/FORGestureTrackDisplay",
    "license": "MIT",
    "authors": {
        "ZhipingYang": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/ZhipingYang/FORGestureTrackDisplay.git",
        "tag": "0.1.0"
    },
    "requires_arc": true,
    "source_files": "FORGestureTrackDisplay/**/*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This