문제

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?

도움이 되었습니까?

해결책

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

ps: subclass the UIWindow

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top