             }
         }
     }
-
+    
+    override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
+        NSLog("will rotate starting to \(toInterfaceOrientation)")
+    }
+    
     // TODO: why does the app crash if this isn't here?
     convenience override init() {
         self.init(nibName: nil, bundle: nil)

                    
                    if key.outputText != nil {
                        keyView.addTarget(self, action: "keyPressed:", forControlEvents: .TouchUpInside)
    //                    keyView.addTarget(self, action: "takeScreenshotDelay", forControlEvents: .TouchDown)
                    }
                    
                    if key.type == Key.KeyType.Character || key.type == Key.KeyType.Period {

    
    override func textDidChange(textInput: UITextInput) {
        // The app has just changed the document's contents, the document context has been updated.
    }
    
    func setHeight() {
        if self.view.frame.height != 0 {
            if self.heightConstraint == nil {
                //for constraint in self.view.constraints() {
                //    var actualConstraint = constraint as NSLayoutConstraint
                //    if let identifier = actualConstraint.identifier {
                //        if identifier == "UIView-Encapsulated-Layout-Height" {
                //            //actualConstraint.constant = 100
                //            actualConstraint.active = false
                //        }
                //    }
                //}
                
                //let defaultHeightPortrait = 216.0
                //let defaultHeightLandscape = 162.0
                //let widthPortrait = 320.0
                //let widthLandscape = 568.0
                //
                //// TODO: add layout binding
                //let actualHeightPortrait = defaultHeightPortrait + 30.0
                //let actualHeightLandscape = defaultHeightLandscape + 30.0
                //
                //let m = (actualHeightPortrait - actualHeightLandscape) / (widthPortrait - widthLandscape)
                //let c = actualHeightPortrait - (widthPortrait * m)
                
                self.heightConstraint = NSLayoutConstraint(
                    item:self.view,
                    attribute:NSLayoutAttribute.Height,
                    relatedBy:NSLayoutRelation.Equal,
                    toItem:nil,
                    attribute:NSLayoutAttribute.NotAnAttribute,
                    multiplier:0,
                    constant:400)
                self.heightConstraint!.priority = 1000
                
                self.view.addConstraint(self.heightConstraint!) // TODO: what if view already has constraint added?
            }
        }
        
        return;
    }
    
    var blah = 0
