【问题标题】:KeyboardAvoidingView does not work with Field in redux-formKeyboardAvoidingView 不适用于 redux 形式的字段
【发布时间】:2019-01-24 11:13:49
【问题描述】:

我使用了来自“react-native”的 KeyboardAvoidingView。一旦我专注于输入字段,键盘仍然会覆盖输入。下面是我的代码

    <KeyboardAvoidingView keyboardVerticalOffset = {0} style = {{ flex: 1 }} behavior = "padding" >  
        <ScrollView>
             <View style={styles.formGroup}>
                   <Text style={styles.labelGroup}>{Question.howToReachJobVacancy }</Text>
                   <Field
                        component={CustomTextInput}
                        multiline={true}
                        numberOfLines={2}
                        placeholder='ចុចទីនេះដើម្បីសរសេរចម្លើយ'
                    />
              </View>
        </ScrollView>

     </KeyboardAvoidingView>

这是我的自定义文本输入。

        <TextField {...inputProps} 
           value={input.value}
           onChangeText={ input.onChange }
           onBlur={input.onBlur}
           onFocus={input.onFocus}
           multiline={true}
           labelHeight={0}}/>

我想修复输入字段上的 iOS 键盘弹出问题。

【问题讨论】:

  • 你需要在render()中使用KeyboardAvoidingView而不是KeyboardAvoiding
  • 你是对的。我编辑了我的问题。

标签: ios reactjs react-native redux-form


【解决方案1】:

请尝试以下代码

<KeyboardAvoidingView behavior={(Platform.OS === 'ios' ? 'padding' : null)} style={{ flex: 0 }}>
        <ScrollView>
             <View style={styles.formGroup}>
                   <Text style={styles.labelGroup}>{Question.howToReachJobVacancy }</Text>
                   <Field
                        component={CustomTextInput}
                        multiline={true}
                        numberOfLines={2}
                        placeholder='ចុចទីនេះដើម្បីសរសេរចម្លើយ'
                    />
              </View>
        </ScrollView>
</KeyboardAvoidingView>

【讨论】:

  • 我认为可能存在与您的特定屏幕设计相关的任何其他问题。如果可能,请分享您的完整视图代码和样式。
猜你喜欢
  • 1970-01-01
  • 2019-02-06
  • 2021-10-17
  • 1970-01-01
  • 2020-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-06
相关资源
最近更新 更多