Last active
December 3, 2015 08:59
-
-
Save 0xlitf/8b30fa1941e9bd4ec310 to your computer and use it in GitHub Desktop.
Cocoa Touch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(@"取消"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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