Created
March 6, 2017 08:41
-
-
Save kbshl/0644099dec58d32ba2ed6bf72d27c861 to your computer and use it in GitHub Desktop.
Appcelerator iOS: Move TableView up if soft keyboard comes up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isKeyboardOpen = false; // used for the iOS keyboard open detection later. | |
// handles the iOS keyboard change event. | |
function onKeyboardFrameChanged(event) { | |
// first, calculate the new position. | |
var newListBottomPosition; | |
if (isKeyboardOpen) { | |
isKeyboardOpen = false; | |
newListBottomPosition = 0; | |
} | |
else { | |
isKeyboardOpen = true; | |
newListBottomPosition = event.keyboardFrame.height; | |
} | |
// Second, animate the table into the new position. | |
$.tableView.animate({ | |
bottom: newListBottomPosition, | |
duration: event.animationDuration * 1000 | |
}); | |
} | |
// Bind events not set in Alloy. | |
OS_IOS && Ti.App.addEventListener('keyboardframechanged', onKeyboardFrameChanged); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment