RHBOrientationObjC 0.2.6

RHBOrientationObjC 0.2.6

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016 年 8 月

Lazar Otasevic 维护。



RHBOrientation 是一个易于使用和可定制的 Objective-C 库,用于根据加速度计数据估计设备方向。

RHBOrientation 使用原始加速度计数据来检测当前手机方向,即使在设备处于“方向锁定”模式下也能工作。

方向检测使用经过正确设计的“方向锁定”算法,并提供可定制的 z 轴和方向锁定阈值。

使用方法

导入 RHBOrientationObjC 头文件

    #import "RHBOrientation.h"

在你的视图控制器(例如 viewDidLoad)中初始化方向检测

    self.orienter = [RHBOrienter new];

任何时候都可以通过以下方式获取方向

    self.orienter.deviceOrientation

可选设置代理并实现代理方法以在方向更改时收到通知。

    self.orienter.delegate = self;

您的类必须遵循 RHBOrienterDelegate 协议并实现该方法

    - (void)didChangeDeviceOrientation:(RHBOrienter *)orienter oldOrientation:(UIDeviceOrientation)oldOrientation newOrientation:(UIDeviceOrientation)newOrientation;

示例

克隆仓库,并打开 Example/RHBOrientationObjC.xcodeproj。由于模拟器不支持加速度计,因此无法在模拟器上进行方向检测。

安装

RHBOrientationObjC 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "RHBOrientationObjC"

作者

Lazar Otasevic, [email protected]

许可证

RHBOrientationObjC 适用于 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。