#if DEBUG
- (BOOL)canBecomeFirstResponder{
return YES;
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
//检测到摇动开始
if (motion == UIEventSubtypeMotionShake){
// your code
UINavigationController *nav = (UINavigationController *)self.selectedViewController;
}
}
#endif
在模拟器中 摇晃是在:Handware->shake Gesture.