             prevLocation = location
         }
     }
-    
-    deinit {
-        if (motionManger.isDeviceMotionActive) {
-            motionManger.stopDeviceMotionUpdates()
-        }
-    }
-    
-}
+}
+
 
 extension CMDeviceMotion {
     

}

@objc public class CTPanoramaController: UIViewController {

    override public var shouldAutorotate: Bool {
        return true
    }
    
    override public var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return .all
    }
    
    override public var prefersStatusBarHidden: Bool {
        return true
    }
    
    public var image: UIImage?
    public var controlMethod = CTPanaromaControlMethod.Touch
    public var panaromaType = CTPanaromaType.Cylindirical
    public var speed = CGPoint(x: 0.005, y: 0.005)
    
    private var sceneView: SCNView!
    private let cameraNode = SCNNode()

        return .Cylindirical
    }
    
    // MARK: Class lifecycle methods
    
    init(image: UIImage) {
        super.init(nibName: nil, bundle: nil)
        self.image = image
    }
    
    public required init?(coder aDecoder: NSCoder) {
        fatalError("Cannot be initialized from a storyboard or nib")
    }
    
    deinit {
        if (motionManger.isDeviceMotionActive) {
            motionManger.stopDeviceMotionUpdates()
        }
    }
    
    override public func viewDidLoad() {
        super.viewDidLoad()

        panaromaType = panoramaTypeForCurrentImage

        prepareUI()
        createScene()

        controlMethod = .Touch
    }
    
    // MARK: Configuration helper methods
    
    private func createScene() {
        let camera = SCNCamera()
        camera.zFar = 100
        camera.xFov = 70
