Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sometimes Accelerometer delegate method is not called

I have an application that uses the accelerometer. Sometimes, the application will launch without the accelerometer data updating. Relaunching the app, sometimes the problem persist, sometimes it doesn't. And even weirder, sometimes I can try 10 times and everything works as expected. Is this a bug, or maybe something I am missing. Debugging, this code is never called when the accelerometer is not updated:

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration;

Any ideas?

like image 714
carlos Avatar asked Oct 30 '08 04:10

carlos


2 Answers

I finally found a work around. This is a known bug. So the work around I found is to start a thread and have this thread check if the accelerometer delegate has been called, if it has, then quit the thread, if not, set the delegate again, and re-test, until the accelerometer delegate gets called. I tested this throughly and it works flawlessly. I hope this gets resolved on the next update of the iPhone OS.

like image 184
carlos Avatar answered Nov 15 '22 14:11

carlos


I have this same problem. It happens perhaps 1/20 times with an app I made from the CrashLanding sample. After I noticed it with my app I grabbed a fresh version of Crashlanding, installed it, and finally got it to start with accelerometer failing.

I don't know how to fix it. Honestly I hate the accelerometer... at least for controlling games :-\

Also, the accelerometer has occasionally failed when I start the "accelerometer" sample project.

like image 43
MrDatabase Avatar answered Nov 15 '22 14:11

MrDatabase