Latest 1.1.1
Homepage https://github.com/seivan/SHGestureRecognizerBlocks
License MIT
Platforms ios 6.0, requires ARC
Authors

CI Status
Version
Platform
License

This pod is used by SHUIKitBlocks as part of many components covering to plug the holes missing from Foundation, UIKit, CoreLocation, GameKit, MapKit and other aspects of an iOS application’s architecture.

Overview

The gestures are automatically removed once their target is gone, so it isn’t necessary to clean up – Swizzle Free(™)

Check the creating section

Create blocks directly from convenience class selectors

Add additional blocks on the gesture recognizer

Check the removing section

Remove specific blocks – will also remove the gesture recognizer from the target if it was the last block
Remove all blocks – will also remove the gesture recognizer from the target

Check the properties section

NSSet with all active blocks on the gesture

Installation

pod 'SHGestureRecognizerBlocks'

Setup

Put this either in specific files or your project prefix file

#import "UIGestureRecognizer+SHGestureRecognizerBlocks.h"

or

#import "SHGestureRecognizerBlocks.h"

Usage

Creating

With SHGestureRecognizerBlocks you can set auto-removed blocks instead of using selectors

  UITapGestureRecognizer * tapRecognizer = [UITapGestureRecognizer SH_gestureRecognizerWithBlock:^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint location) {
    NSLog(@"callback");
  }];

  [self.view addGestureRecognizer:tapRecognizer];

or if you want add additional blocks


  UITapGestureRecognizer * tapRecognizer = [UITapGestureRecognizer alloc] init];

  SHGestureRecognizerBlock block = ^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint location) {
    NSLog(@"CALLBACK block1");
  };

  SHGestureRecognizerBlock block2 = ^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint location) {
    NSLog(@"CALLBACK block2");
  };

  [tapRecognizer SH_addBlock:block];
  [tapRecognizer SH_addBlock:block2];

  [self.view addGestureRecognizer:tapRecognizer];

Removing

Remove specific blocks – will also remove the gesture recognizer from the target if it was the last block

-(void)SH_removeBlock:(SHGestureRecognizerBlock)theBlock;

[tapGesture SH_removeBlock:block];

Remove all blocks – will also remove the gesture recognizer from the target

-(void)SH_removeAllBlocks;

[tapGesture SH_removeAllBlocks];

Properties


NSSet with all active blocks on the gesture

@property(nonatomic,readonly) NSSet * SH_blocks;

for(SHGestureRecognizerBlock block in tapGesture.SH_blocks) {

}

Existing Codebase

Works fine with other gestures, such as swipe, pan and longpresses.

Replacing

[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(performBlockAction:)];

Contact

If you end up using SHGestureRecognizerBlocks in a project, I’d love to hear about it.

email: [email protected]
twitter: @seivanheidari

License

SHGestureRecognizerBlocks is © 2013 Seivan and may be freely
distributed under the MIT license.
See the LICENSE.md file.

Latest podspec

{
    "name": "SHGestureRecognizerBlocks",
    "version": "1.1.1",
    "summary": "Prefixed  UIGestureRecognizer category with blocks, auto-removed. Swizzle free!",
    "description": "n                    Gesture Recognizers with blocks.n                    Blocks are hold with a weak reference so you don't have to cleanup when your object is gone.n  n                    * Swizzle and junk freen                    * No need to clean up after - Blocks and observers are self maintained.n                    * Gestures are referenced in a hash with weak propertiesn                    * Auto remove gestures from view and all actions when removing all the blocksn                    * Prefixed selectors.n                    * Works with existing codebase that uses old fashioned observing delegate calls. n                    * Minimum clutter on top of the public interface.n                    n",
    "homepage": "https://github.com/seivan/SHGestureRecognizerBlocks",
    "license": "MIT",
    "authors": {
        "Seivan Heidari": "[email protected]"
    },
    "source": {
        "git": "https://github.com/seivan/SHGestureRecognizerBlocks.git",
        "tag": "1.1.1"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source_files": "SHGestureRecognizerBlocks/**/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This