如何让指南针转动顺畅
我已经使用以下方法完成了在指南针中旋转指针的编码:
NeedleView.transform=CGAffineTransformMakeRotation(theHeading);
但旋转并不顺利。它正在粗暴地移动。
谁能告诉我如何使罗盘针相对于角运动平滑旋转?
I have done the coding for rotating a needle in a compass using:
NeedleView.transform=CGAffineTransformMakeRotation(theHeading);
but the rotation is not smooth. It is moving roughly.
Can anyone tell me how to do a smooth rotation of the compass needle with respect to angular movement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用陀螺仪补偿罗盘的跳动。我已经使用该方法完成了一个项目,您可以在这里看到: http://www.sundh.com/blog/2011/09/stabalize-compass-of-iphone-with-gyrscope/
You can compensate the jumpiness of the compass with the gyroscope. I have done a project using that method that you can see here: http://www.sundh.com/blog/2011/09/stabalize-compass-of-iphone-with-gyroscope/
试试这个。对我来说效果很好。
Try this. Works well for me.
使用变换制作动画,而不仅仅是设置它。如果你设置了它,它会立即改变旋转。动画会减慢速度。您可以选择动画发生的持续时间以减慢动画速度。有关动画 API,请参阅 UIView 的文档。
Do an animation with the transform, don't just set it. If you set it, it will change rotation right away. Animation will slow it. You can select the duration over which the animation occurs to slow it down. Look at the docs for UIView for the animation APIs.