Reputation: 22708
Is it possible to detect a shake gesture, no matter of the view displayed?
I want to go to the main page of the app whenever the user shakes the device.
Is there any other solution besides putting in each UIView the -motionBegan:withEvent:
method?
Upvotes: 0
Views: 663
Reputation: 16938
Create a subclass of UIViewController
, say UIShakeViewController
, and derive all your view controller classes from UIShakeViewController
.
Then, in UIShakeViewController
, implement your shake detection methods, etc. This way, all your view controllers have the functionality, but you implement the detection code once.
Upvotes: 3