0

I need to have a function that detects a shake without having to add the - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event in every viewController. But when I add the function to the appDelegate, the motion isn't detected. I tried NSNotificationCenter to no avail. I have ton's of viewControllers and adding the motionEnded-method to all of them would be tedious…

Any ideas?

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
Swissdude
  • 3,486
  • 3
  • 35
  • 68

2 Answers2

1

you can add - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event in the AppDelegate.window.

ps: subclass the UIWindow

Lee xw
  • 133
  • 9
0

Create a BaseViewController, put your shake detection methods there and make every controller inherit from it.

alexandresoli
  • 918
  • 1
  • 9
  • 18