     override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
         self.keyboard = defaultKeyboard()
         self.forwardingView = ForwardingView(frame: CGRectZero)
-        self.forwardingView.setTranslatesAutoresizingMaskIntoConstraints(false)
         self.layout = KeyboardLayout(model: self.keyboard, superview: self.forwardingView)
         self.shiftState = .Disabled
         self.currentMode = 0
         
         super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
-        
+            
         self.view.addSubview(self.forwardingView)
-        
-        self.view.addConstraint(
-            NSLayoutConstraint(
-                item: self.forwardingView,
-                attribute: NSLayoutAttribute.Left,
-                relatedBy: NSLayoutRelation.Equal,
-                toItem: self.view,
-                attribute: NSLayoutAttribute.Left,
-                multiplier: 1,
-                constant: 0))
-        self.view.addConstraint(
-            NSLayoutConstraint(
-                item: self.forwardingView,
-                attribute: NSLayoutAttribute.Right,
-                relatedBy: NSLayoutRelation.Equal,
-                toItem: self.view,
-                attribute: NSLayoutAttribute.Right,
-                multiplier: 1,
-                constant: 0))
-        self.view.addConstraint(
-            NSLayoutConstraint(
-                item: self.forwardingView,
-                attribute: NSLayoutAttribute.Top,
-                relatedBy: NSLayoutRelation.Equal,
-                toItem: self.view,
-                attribute: NSLayoutAttribute.Top,
-                multiplier: 1,
-                constant: 0))
-        self.view.addConstraint(
-            NSLayoutConstraint(
-                item: self.forwardingView,
-                attribute: NSLayoutAttribute.Bottom,
-                relatedBy: NSLayoutRelation.Equal,
-                toItem: self.view,
-                attribute: NSLayoutAttribute.Bottom,
-                multiplier: 1,
-                constant: 0))
-        
-        // TODO: figure out where to move this
-        self.layout.initialize()
-        self.setupKeys()
-        
-        // TODO: read up on swift setter behavior on init
-        self.setMode(0)
     }
     
     required init(coder: NSCoder) {
         fatalError("NSCoding not supported")
     }
-
+    
+//    override func updateViewConstraints() {
+//        // suppresses constraint unsatisfiability on initial zero rect; mostly an issue of log spam
+//        // TODO: there's probably a more sensible/correct way to do this
+//        if CGRectIsEmpty(self.view.bounds) {
+//            NSLayoutConstraint.deactivateConstraints(self.layout.allConstraintObjects)
+//        }
+//        else {
+//            NSLayoutConstraint.activateConstraints(self.layout.allConstraintObjects)
+//        }
+//
+//        super.updateViewConstraints()
+//    }
+    
+    var constraintsAdded: Bool = false
+    func setupConstraints() {
+        if !constraintsAdded {
+            self.forwardingView.setTranslatesAutoresizingMaskIntoConstraints(false)
+            
+            self.view.addConstraint(
+                NSLayoutConstraint(
+                    item: self.forwardingView,
+                    attribute: NSLayoutAttribute.Left,
+                    relatedBy: NSLayoutRelation.Equal,
+                    toItem: self.view,
+                    attribute: NSLayoutAttribute.Left,
+                    multiplier: 1,
+                    constant: 0))
+            self.view.addConstraint(
+                NSLayoutConstraint(
+                    item: self.forwardingView,
+                    attribute: NSLayoutAttribute.Right,
+                    relatedBy: NSLayoutRelation.Equal,
+                    toItem: self.view,
+                    attribute: NSLayoutAttribute.Right,
+                    multiplier: 1,
+                    constant: 0))
+            self.view.addConstraint(
+                NSLayoutConstraint(
+                    item: self.forwardingView,
+                    attribute: NSLayoutAttribute.Top,
+                    relatedBy: NSLayoutRelation.Equal,
+                    toItem: self.view,
+                    attribute: NSLayoutAttribute.Top,
+                    multiplier: 1,
+                    constant: 0))
+            self.view.addConstraint(
+                NSLayoutConstraint(
+                    item: self.forwardingView,
+                    attribute: NSLayoutAttribute.Bottom,
+                    relatedBy: NSLayoutRelation.Equal,
+                    toItem: self.view,
+                    attribute: NSLayoutAttribute.Bottom,
+                    multiplier: 1,
+                    constant: 0))
+            
+            self.layout.initialize()
+            self.setupKeys()
+            self.constraintsAdded = true
+            
+            // TODO: read up on swift setter behavior on init
+            self.setMode(0)
+        }
+        
+        self.setHeight()
+    }
+    
+    override func updateViewConstraints() {
+        super.updateViewConstraints()
+        self.setupConstraints()
+    }
+    
     override func viewDidLoad() {
         super.viewDidLoad()
-    }
-    
-    override func viewWillLayoutSubviews() {
-        super.viewWillLayoutSubviews()
-    }
+        self.view.setNeedsUpdateConstraints()
+    }
+    
+//    override func viewWillLayoutSubviews() {
+//        super.viewWillLayoutSubviews()
+//    }
+    
+//    override func viewDidLayoutSubviews() {
+//        super.viewDidLayoutSubviews()
+//        self.setHeight()
+//    }
+    
+//    override func viewDidAppear(animated: Bool) {
+//        self.setHeight()
+//    }
     
     override func viewDidLayoutSubviews() {
         super.viewDidLayoutSubviews()
-    }
-    
-    override func updateViewConstraints() {
-        // suppresses constraint unsatisfiability on initial zero rect; mostly an issue of log spam
-        // TODO: there's probably a more sensible/correct way to do this
-        if CGRectIsEmpty(self.view.bounds) {
-            NSLayoutConstraint.deactivateConstraints(self.layout.allConstraintObjects)
-        }
-        else {
-            NSLayoutConstraint.activateConstraints(self.layout.allConstraintObjects)
-        }
-        
-        super.updateViewConstraints()
+        
+//        self.setHeight()
+        
+//        self.forwardingView.frame = self.view.bounds
     }
     
     func setupKeys() {

    
    override func textDidChange(textInput: UITextInput) {
        // The app has just changed the document's contents, the document context has been updated.
    }
    
    var blah = 0

                    
                    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 {
