【UIKit】-2- UIAccelerometer-加速计事件
2015-07-22 10:07
351 查看
1.官方文档介绍(加速计事件)
The UIAccelerometer classlets you register to receive acceleration-related data from the onboardhardware. As a device moves, its hardware reports linear acceleration changesalong the primary axes in three-dimensional space. You can use this
data todetect both the current orientation of the device (relative to the ground) andany instantaneous changes to that orientation. You might use instantaneouschanges as input to a game or to initiate some action in your application.
You do not createaccelerometer objects directly. Instead, you use the shared UIAccelerometer objectto specify the interval at which you want to receive events and then set itsdelegate property.Upon assigning your delegate object, the accelerometer
object begins deliveringacceleration events to your delegate immediately at the specified interval.Events are always delivered on the main thread of your application.
The maximumfrequency for accelerometer updates is based on the available hardware. You canrequest updates less frequently but cannot request them more frequently thanthe hardware maximum. Once you assign your delegate, however, updates aredelivered
regularly at the frequency you requested, whether or not theacceleration data actually changed. Your delegate is responsible for filteringout any unwanted updates and for ensuring that the amount of change issignificant enough to warrant taking action.
For moreinformation about the data delivered to your observer, see UIAcceleration
Class Reference. Forinformation about implementing your delegate object, see
该UIAccelerometer类,可以注册从板载硬件加速接收相关数据。作为设备移动时,其硬件报告沿在三维空间中的主轴的线性加速度的变化。可以使用此数据,以检测所述设备(相对于地面)和任何瞬间变化至该方向的两个当前方向。您可以使用瞬间变化为输入到游戏或启动应用程序中的一些行动。你不直接创建对象的加速度。相反,您使用的UIAccelerometer对象指定您希望接收事件,然后设置其属性代表的时间间隔。一旦您指定委托对象,加速计对象开始在指定的时间间隔立即交付加速事件的委托。事件总是交付应用程序的主线程上。的最大频率的加速度计的更新是根据可用的硬件。你可以不经常更新的要求,但不能要求他们更频繁地比硬件最大。一旦你分配你的代表,但是,更新定期在您要求的频率交付,加速数据是否真正改变。您的代理负责过滤掉任何不想要的更新,并确保变化量是足够显著以保证采取行动。有关发送到您的观测数据的详细信息,请参阅UIAcceleration类参考。
The UIAccelerometer classlets you register to receive acceleration-related data from the onboardhardware. As a device moves, its hardware reports linear acceleration changesalong the primary axes in three-dimensional space. You can use this
data todetect both the current orientation of the device (relative to the ground) andany instantaneous changes to that orientation. You might use instantaneouschanges as input to a game or to initiate some action in your application.
You do not createaccelerometer objects directly. Instead, you use the shared UIAccelerometer objectto specify the interval at which you want to receive events and then set itsdelegate property.Upon assigning your delegate object, the accelerometer
object begins deliveringacceleration events to your delegate immediately at the specified interval.Events are always delivered on the main thread of your application.
The maximumfrequency for accelerometer updates is based on the available hardware. You canrequest updates less frequently but cannot request them more frequently thanthe hardware maximum. Once you assign your delegate, however, updates aredelivered
regularly at the frequency you requested, whether or not theacceleration data actually changed. Your delegate is responsible for filteringout any unwanted updates and for ensuring that the amount of change issignificant enough to warrant taking action.
For moreinformation about the data delivered to your observer, see UIAcceleration
Class Reference. Forinformation about implementing your delegate object, see
该UIAccelerometer类,可以注册从板载硬件加速接收相关数据。作为设备移动时,其硬件报告沿在三维空间中的主轴的线性加速度的变化。可以使用此数据,以检测所述设备(相对于地面)和任何瞬间变化至该方向的两个当前方向。您可以使用瞬间变化为输入到游戏或启动应用程序中的一些行动。你不直接创建对象的加速度。相反,您使用的UIAccelerometer对象指定您希望接收事件,然后设置其属性代表的时间间隔。一旦您指定委托对象,加速计对象开始在指定的时间间隔立即交付加速事件的委托。事件总是交付应用程序的主线程上。的最大频率的加速度计的更新是根据可用的硬件。你可以不经常更新的要求,但不能要求他们更频繁地比硬件最大。一旦你分配你的代表,但是,更新定期在您要求的频率交付,加速数据是否真正改变。您的代理负责过滤掉任何不想要的更新,并确保变化量是足够显著以保证采取行动。有关发送到您的观测数据的详细信息,请参阅UIAcceleration类参考。
"UIAccelerometer has been replaced by the CoreMotion framework"
1、iOS5.0以前,可以使用UIAcceleration来监听加速计事件。
2、Bug iOS5.0以后,UIAccelerometerDelegate已经被depreacated,
3、针对iOS4.0以上版本,推荐使用CMMotionManager来监听加速计事件。
相关文章推荐
- HDU 5288 OO’s Sequence(多校第一场1001)
- 关于mule中使用jdbc时报No Suitable Driver found错误的问题
- Convert UOM values
- No suitable driver found for jdbc:mysql://localhost:3306/test
- 【UIKit】-1- UIKitDefines.h - 跨平台,包容 C 库
- UISearchBar套接TableView实现搜索功能
- 禁用UITextField的双击出现复制粘贴剪切等操作
- 【Android UI设计与开发】第15期:顶部标题栏(六)实现悬浮式顶部和底部标题栏效果
- IOS中UIview需要知道的一些事情:setNeedsDisplay、setNeedsLayout
- queue的用法以及优先级priority的用法
- hdu contest day1 1001 OO’s Sequence
- IOS 开发之UITableview的基本创建
- OO’s Sequence 2015多校联合1001
- iOS总结控件二(UIButton)
- rabbitmq之back queue草稿
- rabbitmq method之queue.declare
- EF6 CodeFirst+Repository+Ninject+MVC4+EasyUI实践(四)
- LeetCode N-Queens
- LeetCode N-Queens
- RequireJS 模块化加载框架使用