                     self.motionManger.stopDeviceMotionUpdates()
                 }
             })
-            
-        }
-    }
-    
-    private func prepareUI() {
-        sceneView = SCNView()
-        sceneView.translatesAutoresizingMaskIntoConstraints = false
-        view.addSubview(sceneView)
-        
-        let views = ["sceneView" : sceneView!]
-        
-        view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "|[sceneView]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views))
-        view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[sceneView]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views))
-        view.backgroundColor = UIColor.green
+            sceneView.gestureRecognizers?.removeAll()
+        }
+        cameraNode.eulerAngles = SCNVector3Make(0, 0, 0)
+    }
+    
+    // MARK: Event handling methods
+    
+    @objc private func buttonTapped() {
+        if controlMethod == .Touch {
+            controlMethod = .Motion
+        }
+        else {
+            controlMethod = .Touch
+        }
     }
     
     @objc private func handlePan(panRec: UIPanGestureRecognizer) {

            prevLocation = location
        }
    }
    
    deinit {
        if (motionManger.isDeviceMotionActive) {
            motionManger.stopDeviceMotionUpdates()
        }
    }
    
}

extension CMDeviceMotion {
    

}

@objc public class CTPanoramaController: UIViewController {
    
    public var image: UIImage?
    public var panaromaType = CTPanaromaType.Spherical
    public var speed = CGPoint(x: 0.005, y: 0.005)
    
    public var controlMethod: CTPanaromaControlMethod? {
        didSet {
            switchControlMethod(to: controlMethod!)
        }
    }
    
    private var sceneView: SCNView!
    private let cameraNode = SCNNode()
