I am creating an app and currently It has a reaction to a motion shake and this is the code for the shake:
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.type == UIEventSubtypeMotionShake) {}
}
Now the user must really shake hardly for the reaction to happen, is there any more complicated way to detect a light wave, or like 5 light shake’s and then the reaction?
Try the following
in your file’s .h
in your file’s .m
I used a subclass of UIView, you could use whatever you wanted.