gpt4 book ai didi

ios - 在 iOS 上自动填充后 react-native Keyboard.dismiss() 不工作

转载 作者:行者123 更新时间:2023-12-01 16:21:10 26 4
gpt4 key购买 nike

我正在使用 expo 开发一个 react-native 应用。

在我的登录屏幕上,我有两个 TextInputs(带有 textContentType 用户名和密码)。我确实有多个地方可以调用 Keyboard.dismiss()(来自包装 Touchable,来自其他按钮等),这对大多数用例都适用。

我的问题是,当我在 iOS 上成功使用密码自动填充(通过指纹)后,键盘首先会自动隐藏和重新显示(触发所有常见的键盘事件),这看起来很奇怪但可以接受,但之后键盘不再对任何内容使用reactKeyboard.dismiss() 调用直到我聚焦另一个 TextInput。

“使用强密码”键盘覆盖层似乎也存在类似问题。

这是我的版本:

"expo": "^34.0.1",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",

在 iOS 13.2.3 上的 Expo 客户端中运行

提前感谢您的帮助。

编辑:

我将问题简化为最基本的版本。在我使用 iOS 设备上的密码自动填充功能之前,关闭按钮工作正常。

https://github.com/SebastianRoese/tryouts/tree/master/keyboard-dismiss-problem

import React from 'react'
import { View, Button, TextInput, StyleSheet, Keyboard } from 'react-native'

const App = () => {
return (
<View style={styles.screen}>
<TextInput style={styles.textinput} textContentType="username" />
<TextInput style={styles.textinput} secureTextEntry textContentType="password" />
<Button title="Dismiss Keyboard" onPress={() => Keyboard.dismiss()} />
</View>
)
}

const styles = StyleSheet.create({
screen: {
width: '100%',
height: '100%',
paddingVertical: '15%',
backgroundColor: '#1e1e1e',
alignItems: 'center',
},
textinput: {
marginVertical: 10,
padding: 10,
width: '70%',
height: 40,
backgroundColor: '#ababab',
},
})

export default App

最佳答案

从 Expo SDK 34 升级到 Expo SDK 38 后,问题不再重现。

似乎这至少是 Expo SDK 版本 34 中的一个问题。

关于ios - 在 iOS 上自动填充后 react-native Keyboard.dismiss() 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59761162/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com