All Projects → amerhukic → OrientationTracker

amerhukic / OrientationTracker

Licence: MIT license
Track device orientation changes even for devices with orientation-lock turned on.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to OrientationTracker

orientation tracking-unscented kalman filter
Implemented Unscented Kalman Filter (UKF) for orientation tracking. Sensors fusion of accelerometer, and gyroscope
Stars: ✭ 39 (+116.67%)
Mutual labels:  orientation-tracking
saram
Get OCR in txt form from an image or pdf extension supporting multiple files from directory using pytesseract with auto rotation for wrong orientation. PYPI:
Stars: ✭ 51 (+183.33%)
Mutual labels:  orientation-detection
memento
Organize your meme image cluster in a better format using OCR from the meme to sort them using tesseract along with editing memes by segmenting them using OpenCV within a directory
Stars: ✭ 70 (+288.89%)
Mutual labels:  orientation-detection
device-orientation
React hook for the Device Orientation API
Stars: ✭ 23 (+27.78%)
Mutual labels:  device-orientation

Logo

Pod Version License Twitter: @hukicamer

OrientationTracker is a Core Motion based library for tracking device orientation changes. It also works for devices with orientation-lock turned on. You can subscribe to orientation change notifications and react accordingly.

Requirements

  • iOS 8.0+
  • Xcode 10.2
  • Swift 5.0

Usage

To start device orientation tracking use OrientationTracker you simply invoke the startDeviceOrientationTracking method, preferably in AppDelegate :

DeviceOrientationDetector.shared.startDeviceOrientationTracking()

You then add an observer for the OrientationTracker.deviceOrientationChangedNotification and react to orientation changes:

NotificationCenter.default.addObserver(self, selector: #selector(updateViews), name: DeviceOrientationDetector.deviceOrientationChangedNotification, object: nil)

You can access the current orientation using the currentDeviceOrientation property.

To stop receiving notifications use the stopDeviceOrientationTracking method:

DeviceOrientationDetector.shared.stopDeviceOrientationTracking()

If your app supports portrait mode only, you can use the affineTransform property to rotate views when the orientation changes:

UIView.animate(withDuration: 0.2) {
    self.imageView.transform = DeviceOrientationDetector.shared.affineTransform
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate OrientationTracker into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'OrientationTracker'
end

Then, run the following command:

$ pod install

Author

Amer Hukić

License

OrientationTracker is licensed under the MIT license. Check the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].