Skip to content

Instantly share code, notes, and snippets.

@0xlitf
Last active December 3, 2015 08:59
Show Gist options
  • Save 0xlitf/8b30fa1941e9bd4ec310 to your computer and use it in GitHub Desktop.
Save 0xlitf/8b30fa1941e9bd4ec310 to your computer and use it in GitHub Desktop.
Cocoa Touch
#pragma mark shake
- (BOOL)canBecomeFirstResponder
{
return YES;// default is NO
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"开始摇动手机");
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"stop");
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"取消");
}
- (UIViewController *)viewController {
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment