     
     public func textFieldDidBeginEditing(_ textField: UITextField) {
         
-        guard let customField = textField as? SBAStepTextField else { return }
-        
-        savedVerticalScrollOffet = tableView!.contentOffset.y
-        tableView?.scrollToRow(at: customField.indexPath!, at: .bottom, animated: true)
+        activeTextField = textField
+        scroll(to: textField)
+        
+//        guard let customField = textField as? SBAStepTextField else { return }
+//        
+//        savedVerticalScrollOffet = tableView!.contentOffset.y
+//        tableView?.scrollToRow(at: customField.indexPath!, at: .middle, animated: true)
     }
     
     public func textFieldDidEndEditing(_ textField: UITextField) {
+        
+        // clear the activeTextField if this is that textField
+        if textField === activeTextField {
+            activeTextField = nil
+        }
         
         // scroll back to our saved offset
         tableView?.setContentOffset(CGPoint(x: 0.0, y: savedVerticalScrollOffet), animated: true)
+    }
+    
+    func scroll(to textField: UITextField?) {
+        guard let customField = textField as? SBAStepTextField else { return }
+        savedVerticalScrollOffet = tableView!.contentOffset.y
+        tableView?.scrollToRow(at: customField.indexPath!, at: .middle, animated: true)
     }
     
     

    var originalResult: ORKStepResult!
    var userHasContinued = false
    
    
    var tableViewInsetBottom: CGFloat {
        get {

                
                let answerFormat = tableItem?.formItem?.answerFormat?.implied()
                let type = answerFormat?.questionType
                
                // set keyboard type
                if let textAnswerFormat = answerFormat as? ORKTextAnswerFormat {
                    // use the keyboard type defined for this step
                    fieldCell.textField.keyboardType = textAnswerFormat.keyboardType
                    fieldCell.textField.isSecureTextEntry = textAnswerFormat.isSecureTextEntry
                }
                else {
                    // use the keyboard type appropriate for the questionType
