RHBOrientationObjC 0.2.6

RHBOrientationObjC 0.2.6

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Aug 2016

Maintained by Lazar Otasevic.



RHBOrientation is an easy to use and customizable Objective-C library for estimating device orientation based on accelerometer data.

RHBOrientation uses raw accelerometer data to detect current phone orientation, and it works even when device is in "Orientation Lock" mode.

Orientation detection uses PROPERLY designed "orientation snapping" algorithm with customizable z-axis and orientation snapping treshold value.

Usage

Import RHBOrientationObjC header file:

    #import "RHBOrientation.h"

Initialize orientation detection (for example in viewDidLoad) in your view controller:

    self.orienter = [RHBOrienter new];

Obtain orientation anytime using:

    self.orienter.deviceOrientation

Optionally setup delegate and implement delegate method to get notifications whenever orientation changes.

    self.orienter.delegate = self;

Your class must comply to RHBOrienterDelegate protocol and implement method:

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

Example

Clone the repo, and open Example/RHBOrientationObjC.xcodeproj. Orientation detection does not work in Simulator, since simulator does not support accelerometer.

Installation

RHBOrientationObjC is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "RHBOrientationObjC"

Author

Lazar Otasevic, [email protected]

License

RHBOrientationObjC is available under the MIT license. See the LICENSE file for more info.