简体   繁体   English

在iOS上,当TextInput焦点位于键盘后面时(本机)

[英]on ios when TextInput focused it's behind keyboard (react-native)

I am using listView with TextInputs, on ios when TextInput focused it's behind keyboard. 我在iOS上将ListView与TextInputs一起使用时,当TextInput将其聚焦在键盘后面时。 How to fix it? 如何解决?

Sample code: http://rnplay.org/apps/8baZSA 示例代码: http : //rnplay.org/apps/8baZSA

You need to use <ScrollView> instead of <View> in order to use this method. 您需要使用<ScrollView>而不是<View>才能使用此方法。

The key method is scrollResponderScrollNativeHandleToKeyboard(refToElement, scrollHeight, preventNegativeOffset) (sounds cool, right ;)) 关键方法是scrollResponderScrollNativeHandleToKeyboard(refToElement, scrollHeight, preventNegativeOffset) (听起来很酷,右边;))

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) 
}

Seems this thread is what you're looking for. 似乎此线程是您想要的。

TL;DR: see this stackoverflow question TL; DR: 请参阅此stackoverflow问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM