有时不调用加速度计委托方法

发布于 2024-07-07 18:20:25 字数 298 浏览 7 评论 0原文

我有一个使用加速度计的应用程序。 有时,应用程序将在没有更新加速度计数据的情况下启动。 重新启动应用程序,有时问题仍然存在,有时则不会。 更奇怪的是,有时我可以尝试 10 次,一切都按预期进行。 这是一个错误,还是我缺少的东西。 调试,当加速度计未更新时,永远不会调用此代码:

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

有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

箜明 2024-07-14 18:20:25

我终于找到了解决办法。 这是一个已知的错误。 因此,我发现的解决方法是启动一个线程并让该线程检查是否已调用加速度计委托,如果已调用,则退出线程,如果没有,则再次设置委托,然后重新测试,直到加速度计委托被调用被叫。 我对此进行了彻底测试,它工作完美。 我希望这个问题能够在 iPhone 操作系统的下一次更新中得到解决。

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.

饮惑 2024-07-14 18:20:25

我有着同样的问题。 我根据 CrashLanding 示例制作的应用程序可能会发生 1/20 次这种情况。 当我在我的应用程序中注意到这一点后,我抓住了新版本的 Crashlanding,安装了它,最后让它启动,但加速计失败了。

我不知道如何解决它。 老实说,我讨厌加速计......至少对于控制游戏来说:-\

另外,当我启动“加速计”示例项目时,加速计偶尔会失败。

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.

梦萦几度 2024-07-14 18:20:25

正如其他人提到的,这是一个已知的错误; 我已经向 Apple 记录了该错误(Bug Reporter 问题 ID 6093028),也许其他人也这样做了。 据我所知,所有使用 UIAccelerometer 的应用程序(包括 Apple 的示例应用程序)都会遇到此问题,尽管出现的频率各不相同。

As others have mentioned, this is a known bug; I have logged the bug with Apple (Bug Reporter problem ID 6093028), perhaps others have done so as well. As far as I know, all apps that makes use of UIAccelerometer (including Apple's sample apps) suffer from this issue, though the frequency of occurance varies.

红焚 2024-07-14 18:20:25

FWIW,我的应用程序被广泛使用,它使用加速度计,我从来没有遇到过这个问题。

我的用例可能与您的不同:我仅在应用程序启动后根据用户请求启用它。

FWIW, my app is widely used and it uses the accelerometer, and I've never had this problem.

My use case may be different than yours: I only enable it on user request, well after the application is launched.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文