I am trying to implement shake recognition that works throughout my application. To do this, I add the following code to my xxxAppDelegate.m:
-(BOOL)canBecomeFirstResponder { return YES; } - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventSubtypeMotionShake) { NSLog(@"Shaken, not stirred."); } }
But since in the .h file the delegate is defined as
@interface xxxAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>
I can not use
[self becomeFirstResponder]
in .m so that the application passes the first responder. Therefore, of course, this will not work. What would be the best way to make it work?
source share