I am trying to detect when the phone is shaken in my app so in my ViewController classs, I added the following code:
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"motionEnded");
if (motion == UIEventSubtypeMotionShake)
{
NSLog(@"The phone was shaken!!");
}
}
It worked a few times but essentially it is sporadic. By sporadic I mean that if I run the application and the method is called, then it is called all the time and I can detect shakes. Other times, when I fire up the application (I do make code changes but generally not to this method), it simply will never get called when I shake my phone. My hand is actually sore cause I was trying to shake my phone so much. I even tried another phone to make sure it wasn't the device that wasn't broken.
I am using iPhone OS 3.0
Any idea?
Thanks