Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 反应本机滚动视图不';t从内部文本输入滚动_Reactjs_React Native - Fatal编程技术网

Reactjs 反应本机滚动视图不';t从内部文本输入滚动

Reactjs 反应本机滚动视图不';t从内部文本输入滚动,reactjs,react-native,Reactjs,React Native,我在滚动视图中添加了多文本输入。问题是,当我想从文本输入的内部向下滚动时,我把手指放在文本输入中向下滚动,但它不会向下滚动页面,有没有办法解决这个问题? 下面是一个示例代码: export default class ScrollViewWithTextInput extends React.Component { render() { <ScrollView> <TextInput style={styles.input}

我在滚动视图中添加了多文本输入。问题是,当我想从文本输入的内部向下滚动时,我把手指放在文本输入中向下滚动,但它不会向下滚动页面,有没有办法解决这个问题? 下面是一个示例代码:

export default class ScrollViewWithTextInput extends React.Component {
render() {
    <ScrollView>
        <TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        />
        <TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        /><TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        /><TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        />
        <TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        />
        <TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        /><TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        /><TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        />
    </ScrollView>
}}
const styles = StyleSheet.create({
Container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    marginTop: 8
},
input: {
    width: 350,
    height: 100,
    margin: 5,
    borderColor: 'black',
    borderWidth: 2,
    textAlign: 'right'
}})
导出默认类ScrollViewWithTextInput扩展React.Component{
render(){
}}
const styles=StyleSheet.create({
容器:{
弹性:1,
为内容辩护:“中心”,
对齐项目:“居中”,
玛金托普:8
},
输入:{
宽度:350,
身高:100,
差额:5,
边框颜色:“黑色”,
边界宽度:2,
text对齐:“右”
}})

出于某种原因,将
多行={true}
设置为文本输入对我来说很有效


不太清楚为什么。更奇怪的是,如果同时使用
keyboardType='numeric'

将每个输入作为一个组件,则它将不起作用。试着这样做:

<TouchableOpacity onPress={()=>this.input.focus()} >
    <View pointerEvents="none" >
        <TextInput ref = {(input) => this.input = input} />
    </View>
</TouchableOpacity>
this.input.focus()}>
this.input=input}/>

这将起到调整输入高度的作用。 我真的不明白为什么,但它解决了我的问题。

设置


我们可能会看到您的代码我添加了一个示例代码,奇怪的是,当我将textAlign设置为“left”时,它在“center”或“right”1上不起作用。可能当文本向右或居中对齐时,整个输入被视为“填充了文本”,但在默认的“左”位置,TextInput假定文本仅位于我们看到的位置。2.我在iOS上检查了你的应用程序,滚动正常。3.你的代码中缺少return语句。问题出现在android中,如果我删除textAlign和placeholder,它就会工作,如果placeholder存在,我应该滚动两次,然后它就会工作,我认为这是一个非常恼人的错误。顺便说一句,谢谢你的帮助,还有一件事,不管是否设置了textAlign,当我使用rtl语言时,问题是存在的
<TouchableOpacity
         activeOpacity={1}
         onPress={()=>this.input.focus()}>
         <View
               pointerEvents="none">
               <TextInput
                  ref = {(input) => this.input = input}
               />
         </View>
    </TouchableOpacity>
constructor(props) {
    super(props);
    this._keyboardDidHide = this._keyboardDidHide.bind(this)
    this.onSubmitEditing = this.onSubmitEditing.bind(this)
}

componentWillMount () {
    this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide)
};
componentWillUnmount () {
    this.keyboardDidHideListener.remove();
}
_keyboardDidHide(){
    this.input.blur()
}