Author Topic: Moving UI Out of the Way of the iOS Keyboard  (Read 2776 times)

yevdokia

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 5
    • View Profile
Moving UI Out of the Way of the iOS Keyboard
« on: March 24, 2014, 09:27:12 AM »
I have a login screen with 3 UIInput fields in an iPad game. When the user taps an input field, the iOS keyboard slides on and covers the input field. This seems like something that a lot of apps and games need to deal with. Is there an existing NGUI solution for moving the screen up when the keyboard comes up, or do I need to implement my own?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Moving UI Out of the Way of the iOS Keyboard
« Reply #1 on: March 24, 2014, 05:55:59 PM »
You wouldn't be moving your UI. You would adjust the Camera's Viewport Rect instead. NGUI will adjust automatically.

yevdokia

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Moving UI Out of the Way of the iOS Keyboard
« Reply #2 on: March 25, 2014, 02:09:32 PM »
When I play with the Camera's Viewport Rect, I see the UI scale to fit within the new area, but that's not quite the effect that I want. I'd rather have it look like the UI simply moves up until the currently selected input field is above the top of the keyboard. Is there a simple way to do that?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Moving UI Out of the Way of the iOS Keyboard
« Reply #3 on: March 26, 2014, 02:36:56 AM »
If your UI is not anchored to the screen, then you can simply move some root object up (not UIRoot, but rather root of your UI):

UIRoot
- UI camera
- Root object (move this)
-- The rest of your UI is a child of the "Root object".

yevdokia

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Moving UI Out of the Way of the iOS Keyboard
« Reply #4 on: April 25, 2014, 10:40:04 AM »
Oops! I forgot to respond to your answer. It worked! Thank you so much!

Yevdokia

hexaust

  • Newbie
  • *
  • Thank You
  • -Given: 14
  • -Receive: 1
  • Posts: 35
    • View Profile
Re: Moving UI Out of the Way of the iOS Keyboard
« Reply #5 on: August 28, 2014, 04:38:36 AM »
@yevdokia: can you share some insight on how you did this? I currently facing the same 'problem'. Thank you!