gpt4 book ai didi

javascript - react native textInput scrollView android

转载 作者:行者123 更新时间:2023-11-29 10:34:00 25 4
gpt4 key购买 nike

我正在尝试编写一个非常简单的应用程序来测试 React Native。

我在一个大的 ScrollView 中有一些 TextInput 组件,作为寄存器公式。

一切正常,但当我滚动点击 TextInput 时,它不会滚动。

只有在空白处单击时,我才能滚动浏览页面。知道怎么做吗?

谢谢。

<ScrollView>
<TextInput onChangeText={email => this.setState({email})} label={ I18n.t("contactEmail") }/>
<TextInput onChangeText={email => this.setState({email})} label={ I18n.t("contactEmail") }/>
<TextInput onChangeText={email => this.setState({email})} label={ I18n.t("contactEmail") }/>
<TextInput onChangeText={email => this.setState({email})} label={ I18n.t("contactEmail") }/>
</ScrollView>

最佳答案

我遇到了同样的问题,搜索了一段时间后没有答案帮助我;所以我通过放置 <TouchableWithoutFeedback /> 自己解决了它在每个 <TextInput>并将触摸事件发送回 <TextInput /> :

<View>
<TextInput ref ={(ref)=>this.textInput = ref}>
<TouchableWithoutFeedback style={{position: 'absolute', top:0, bottom:0, left:0, right:0}}
onPress={()=>this.textInput.focus()}/>
</View>

您可以创建一个像那样包装 TextInput 的自定义组件,并在您的 ScrollView 中使用它们。

关于javascript - react native textInput scrollView android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39751162/

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