Created
July 31, 2017 19:08
-
-
Save PabloDomine/6f09484670225d8adbd5c7e7f58db822 to your computer and use it in GitHub Desktop.
Using my own class DeviceOrientationHelper to determine device orientation based on accelerometer motion data readouts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
private var deviceOrientationHelper = DeviceOrientationHelper() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
deviceOrientationHelper.startDeviceOrientationNotifier { (deviceOrientation) in | |
self.orientationChanged(deviceOrientation: deviceOrientation) | |
} | |
} | |
override func viewDidDisappear(_ animated: Bool) { | |
deviceOrientationHelper.stopDeviceOrientationNotifier() | |
super.viewDidDisappear(animated) | |
} | |
private func orientationChanged(deviceOrientation: UIDeviceOrientation) { | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment