Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakemarsh/JMWhenTapped
Easily assign touch down, touch up, and tapped actions to UIViews using blocks.
https://github.com/jakemarsh/JMWhenTapped
Last synced: 3 months ago
JSON representation
Easily assign touch down, touch up, and tapped actions to UIViews using blocks.
- Host: GitHub
- URL: https://github.com/jakemarsh/JMWhenTapped
- Owner: jakemarsh
- License: mit
- Created: 2011-03-17T01:49:01.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2015-10-27T07:57:32.000Z (about 9 years ago)
- Last Synced: 2023-10-20T20:34:02.162Z (over 1 year ago)
- Language: Objective-C
- Homepage: http://deallocatedobjects.com/2011/04/27/save-time-and-code-with-jmwhentapped/
- Size: 933 KB
- Stars: 202
- Watchers: 10
- Forks: 24
- Open Issues: 2
-
Metadata Files:
- Readme: README.markdown
- License: MIT-LICENSE
Awesome Lists containing this project
- awesome - JMWhenTapped - Easily assign touch down, touch up, and tapped actions to UIViews using blocks. (etc)
- awesome - JMWhenTapped - Easily assign touch down, touch up, and tapped actions to UIViews using blocks. (etc)
README
## What is it?
`JMWhenTapped` is a simple little syntactical-sugar addition to all `UIView` objects, as well as any class that inherits from `UIView`. It allows you to assign touch-up, touch-down, tapped (touched down then up), double taps and two finger taps actions to a `UIView` object using a convenient blocks-style syntax. (Examples shown below).
## Installation
Clone the repo. Add the `JMWhenTapped` folder to your iOS 4 project. `#import "JMWhenTapped.h"` wherever you'd like to use the syntax.
## Examples & Usage
Use it like this:
[myView whenTapped:^{
NSLog(@"I was tapped!");
}];
Or like this:[myView whenTouchedDown:^{
NSLog(@"I was touched down!");
}];
And also like this:[myView whenTouchedUp:^{
NSLog(@"I was touched up!");
}];This works the same way with double tap and two finger taps.
## The Different Actions
The `whenTapped:` method should be used in cases where you simply want something to happen when the user taps on a view (i.e. you are concerned with performing some action when their finger is down then up, like changing to a "pressed" state.)
The `whenDoubleTapped:` method should be used when you want to check for double taps on your view.
The `whenTwoFingerTapped:` method should be used when you want to check for single taps made with two fingers (like in Maps.app).
The `whenTouchedDown:` method should be used when you want to trigger some action when the user touches down on your view.
The `whenTouchedUp:` method should be used when you want to trigger some action when the user touches up on your view.
## Demo
Included in this repo is a demo Xcode project that illustrates a quick example of how to use `JMWhenTapped`.