React Native – FlatList向上滚动至键盘底部

时间:2020-07-01 19:25:22

标签: react-native react-native-flatlist

<figure>
  <a href="https://ibb.co/CbSzPRr">
    <img src="https://i.ibb.co/CbSzPRr/Published-06-Retouced-Untagged.jpg" alt="Published-06-Retouced-Untagged" border="0">
  </a>
  <br>
  <figcaption>
    <div>Retouched, Untagged</div>
  </figcaption>
</figure>

到目前为止,我已经实现了想要的目标。但是,当键盘抬起时,它将隐藏FlatList呈现的项目的底部。用户无法滚动并查看最后一项,因为它们留在键盘后面。 如何在保持键盘打开状态(并禁用关闭键盘功能)的同时能够查看和滚动FlatList的全部内容?

1 个答案:

答案 0 :(得分:2)

我相信您在ios中面临此问题。要使用平面列表处理键盘,您可以尝试react-native-keyboard-aware-scroll-view

您可以通过在键盘感知滚动视图中添加此属性来防止键盘关闭。

producer.send(record, callback)

def callback: Callback = new Callback {
    override def onCompletion(recordMetadata: RecordMetadata, e: Exception): Unit = {
      if(null != e) {
         if (e == RecordTooLargeException || e == UnknownServerException || ..) {
            log.error("Winter is comming") //it's non-retriable
            writeDiscardRecordsToSomewhereElse
         } else {
            log.warn("It's no that cold") //it's retriable
         }
      } else {
        log.debug("It's summer. Everything is fine")
      }
    }
}

使用KeyboardAwareScrollView尝试此属性

请参考以下代码段

keyboardShouldPersistTaps={"handled"}

仍然面对问题,请立即回复我。