【发布时间】:2020-05-02 19:05:34
【问题描述】:
我正在使用 expo 开发一个 react-native 应用程序。
在我的登录屏幕上,我确实有两个 TextInput(带有 textContentType 用户名和密码)。
我确实有多个地方可以调用Keyboard.dismiss()(来自包装的Touchable,来自其他按钮等),这对于大多数用例都适用。
我的问题是,在我在 iOS 上成功使用密码自动填充(通过指纹)后,首先键盘隐藏并自动重新显示(触发所有常见的键盘事件),这看起来很奇怪,但可以接受,但之后键盘不再对任何内容做出反应Keyboard.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
【问题讨论】:
-
您介意分享您遇到问题的整个组件的代码吗?
-
嗨@James,我添加了一个精简版本,可以让我始终如一地重现问题。
标签: ios react-native keyboard expo autofill