Skip to content

Instantly share code, notes, and snippets.

@kbshl
Created March 6, 2017 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbshl/0644099dec58d32ba2ed6bf72d27c861 to your computer and use it in GitHub Desktop.
Save kbshl/0644099dec58d32ba2ed6bf72d27c861 to your computer and use it in GitHub Desktop.
Appcelerator iOS: Move TableView up if soft keyboard comes up
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