         
         // If the phone is not already in landscape mode, wait until it is before pushing the Brain Baseline
         // view controller. Otherwise just go for it.
-        let orientation = UIDevice.current.orientation;
-        if (!(orientation == UIDeviceOrientation.landscapeLeft || orientation == UIDeviceOrientation.landscapeRight)) {
+        let orientation = UIApplication.shared.statusBarOrientation
+        if (!(orientation == UIInterfaceOrientation.landscapeLeft || orientation == UIInterfaceOrientation.landscapeRight)) {
             instructionLabel.text = self.step?.text
             self.rotationObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name.UIDeviceOrientationDidChange, object: nil, queue: OperationQueue.main, using: { (notification) in
                 
                 // If the new orientation is landscape mode, remove the notification observer and push the Brain
                 // Baseline view controller. Otherwise keep waiting.
-                let orientation = UIDevice.current.orientation;
-                if (orientation == UIDeviceOrientation.landscapeLeft || orientation == UIDeviceOrientation.landscapeRight) {
+                let orientation = UIApplication.shared.statusBarOrientation
+                if (orientation == UIInterfaceOrientation.landscapeLeft || orientation == UIInterfaceOrientation.landscapeRight) {
                     self.removeRotationObserver()
                     self.deviceDidRotate()
                 }

    
}

open class SBABrainBaselineStepViewController: ORKStepViewController {
    
    open class var nibName: String {

    override open func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        
        // hack to force orientation to a default allowed value before going forward
        if let defaultMask = (UIApplication.shared.delegate as? SBAAppDelegate)?.defaultOrientationLock,
            let forcedOrientation = defaultMask.forcedOrientation(for: UIApplication.shared.statusBarOrientation)
            {
                UIDevice.current.setValue(forcedOrientation.rawValue, forKey: "orientation")
        }
        
        // Note: syoung 07/11/2017 This method is called *after* the OS sets up to dismiss the view
        // so also need to reset in the scheduled activity manager. (belt + suspenders)
