Latest | 0.2.0 |
---|---|
Homepage | https://github.com/confidenceJuice/DHCShakeNotifier |
License | MIT |
Platforms | ios , requires ARC |
Frameworks | Foundation, UIKit |
Authors |
A tiny category, with a single method to send out a NSNotifiatication if a shake is detected :)
Installation
CocoaPods (preferred)
add the following to your Podfile
pod "DHCShakeNotifier"
Manual
add contents of DHCShakeNotifier
to your project
Usage
Clone/ download the repo and take a quick look at the demo.
-
import DHCShakeNotifier:
#import "UIWindow+DHCShakeRecognizer.h"
-
listen for shake notification by adding an NSNotification observer :
@implementation YourObject ... -(id)init{ if (self==[super init]) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(methodThatIsCalledAfterShake) name:DHCSHakeNotificationName object:nil]; } return self; } ... -(void)methodThatIsCalledAfterShake{ NSLog(@""I have just been shaken" - A martini after being ordered by James Bond"); } ... -(void)dealloc{ [[NSNotificationCenter defaultCenter] removeObserver:self name:DHCSHakeNotificationName object:nil]; } ... @end
Latest podspec
{ "name": "DHCShakeNotifier", "version": "0.2.0", "summary": "A very simple category that sends out an NSNotification whenever the device is shaken.", "homepage": "https://github.com/confidenceJuice/DHCShakeNotifier", "license": "MIT", "authors": { "Daniel Haight": "[email protected]" }, "source": { "git": "https://github.com/confidenceJuice/DHCShakeNotifier.git", "tag": "0.2.0" }, "platforms": { "ios": null }, "source_files": "DHCShakeNotifier", "frameworks": [ "Foundation", "UIKit" ], "requires_arc": true }
Sun, 06 Mar 2016 08:08:03 +0000