0

I am using listView with TextInputs, on ios when TextInput focused it's behind keyboard. How to fix it?

Sample code: http://rnplay.org/apps/8baZSA

Maksim
  • 2,396
  • 6
  • 18
  • 27

2 Answers2

0

You need to use <ScrollView> instead of <View> in order to use this method.

The key method is scrollResponderScrollNativeHandleToKeyboard(refToElement, scrollHeight, preventNegativeOffset) (sounds cool, right ;))

I have:

<TextInput ref='ccName' onFocus={(() => this.onFieldFocus('ccName'))} />

where function looks like:

onFieldFocus(fieldName) {
  this.setTimeout(() => {
    let scrollResponder = this.refs.scrollView.getScrollResponder()
    scrollResponder.scrollResponderScrollNativeHandleToKeyboard(
      React.findNodeHandle(this.refs[fieldName]), 200, true
    )
  }, 125) 
}
Samuli Hakoniemi
  • 18,740
  • 1
  • 61
  • 74
0

Seems this thread is what you're looking for.

TL;DR: see this stackoverflow question

Community
  • 1
  • 1
Alexey Kureev
  • 1,978
  • 15
  • 25