How to "shrink" the screen when Keyboard shows up? (iOS)

You must Login before you can answer or comment on any questions.

I think the title says it all, how is it possible to manipulate the icons ans buttons and such when the keyboard shows up? Because when the keyboard shows up, it covers up some of my content.

Thanks very much!

3 Answers

Accepted Answer

Try to add

FieldLogin.adEventListener('blur', function(){
    sv.scrollTo(0,0);
});

— answered 2 years ago by Dan Tamas
answer permalink
2 Comments
  • It worked very well!

    Just a small question, is there a way to make the background image to scroll aswell together with the textfield?

    Thanks so much!

    — commented 2 years ago by Lucas Henrique Pinto

  • use an image view into the sv and under the field

    — commented 2 years ago by Dan Tamas

Put everything in a scrollview. Will scroll for you when u show the keyboard.

— answered 2 years ago by Dan Tamas
answer permalink
5 Comments
  • Thanks for your reply, but it dont solve my problem because now the fields can be scrolled =/ (and adding TouchEnabled : false makes the fields to not be clickable at all)....

    — commented 2 years ago by Lucas Henrique Pinto

  • Then put your fields in a wrapper view and on the fields focus event animate the wrapper to top, and on blur animate it to bottom.

    — commented 2 years ago by Dan Tamas

  • I solved this just by adding contentHeight and contentWidth both to 'auto'... thanks for your help! =DD

    — commented 2 years ago by Lucas Henrique Pinto

  • Show 2 more comments

I tried on a "naked app" and even this way, it dont come back to normal after keyboard is closed... any tips? :( Using scroll view works, but dont come back after the keyboard is closed... thanks!!!

— answered 2 years ago by Lucas Henrique Pinto
answer permalink
2 Comments
  • Post some code

    — commented 2 years ago by Dan Tamas

  • I am trying this just for testing:

    var win = Ti.UI.createWindow ({
     
    });
     
    var FieldLogin = Titanium.UI.createTextField({
        font : {
            fontFamily : 'Helvetica Neue',
            fontSize : '13dp'
        },
        hintText : 'Digite aqui seu login',
        top : '60%',
        left : '10%',
        height : '8%',
        width : '60%',
        borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
    });
     
    var sv = Ti.UI.createScrollView({
     contentHeight : 'auto' //Tried commenting this already
    });
     
    sv.add(FieldLogin);
    win.add(sv);
    win.open();
    But still don't come back after keyboard is closed! (PS: Using iPhone simulator)

    — commented 2 years ago by Lucas Henrique Pinto

Your Answer

Think you can help? Login to answer this question!