找出 iPhone 中的碰撞力
我必须开发一个应用程序。我必须在自行车上安装一个像车速表这样的指示器。
iPhone 被放在汽车的角落里。
iPhone 被放置在车内,无法掉落到任何地方,甚至无法移动。 (车内有一个专门放置iPhone的地方)。
现在,汽车的发展进展顺利。
指示器指示零——这是顺利的方式。
假设汽车经过一个颠簸处。
iPhone 应该跟踪这些移动。如果凹凸很大:
- iPhone 应显示 - 巨大凹凸 - 最大指示器
如果凹凸较低:
- iPhone 应显示 - 正常凹凸 - 指示器中间
其他:
- iPhone 应显示 - 平滑道路 - 零指示器
我知道如何添加抖动处理程序,如给定的在以下链接中: iPhone 中的加速计范围
但是这里 iPhone 不会摇晃吗?它是在固定的地方。
解决方案应该是什么?
I have to develop an application. I have to put an indicator like speedometer in the bike.
iPhone is put in the corner of a Car.
The iPhone is in a placed in a car, from where it can't be dropped anywhere and can't be moved even. ( There is a special place in car where user place iPhone ).
Now, Car is going on a smooth way.
Indicator indicates zero - that is smooth way.
Suppose, a bump is passed by the car.
These movement should be tracked by iPhone. If bump is huge:
- iPhone should display - huge bump - maximum indicator
If bump is low:
- iPhone should display - normal bump - middle at indicator
else:
- iPhone should display - smooth road - zero indicator
I know how to add shake handler, as given in following link:
accelerometer range in iPhone
But here iPhone is not going to be shake? It is in fixed place.
What should be the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用 UIAccelerometer、UIAccelerometerDelegate 和UIAcceleration 类。这是一些示例代码。
You'll need to use the UIAccelerometer, UIAccelerometerDelegate, and UIAcceleration classes. Here is some Sample Code.
iPhone 会晃动 - 它连接到汽车上,汽车也会晃动。您应该能够使用与用手摇动相同的代码。
The iPhone will be shaking - it's attached to the car, and the car will be shaking. You should be able to use the same code as you would if you were shaking it with your hand.