我正在使用 KeyboardAvoidingView 用键盘向上移动按钮,其中我有一个 ScrollView ,其中 keybordShouldPersistTaps 设置为始终,在 ScrollView 中,我使用 Formik 表单。我仍然需要双击按钮两次才能让键盘关闭并提交我的数据。我一直尝试手动关闭/处理 ScrollView 上的键盘,但没有成功,我应该尝试其他方法吗?
<KeyboardAvoidingView style={{ flex: 1 }} behavior={'padding'}>
<ScrollView contentContainerStyle={{ flexGrow: 1 }} keyboardShouldPersistTaps={'always'}>
<Formik
initialValues={this.state}
validationSchema={this.schema}
onSubmit={(values, actions) => {
actions.setSubmitting(false);
}}
render={({ handleBlur, handleChange, handleSubmit, values, isValid }) => {
return (
<View style={onboardingStyles.inputContainer}>
<View>
<Text theme={theme} style={onboardingStyles.headerText}>
{i18n.t('phone_verify')}
</Text>
<TextInput
activeHighlight
value={RizeCore.util.formatPhoneDOM(values.phone)}
onChangeText={(val: string) => {
const phone = RizeCore.util.parseOutDigits(val, 10);
return handleChange('phone')(phone);
}}
onBlur={() => handleBlur('phone')}
label={i18n.t('phone_number')}
style={onboardingStyles.input}
labelStyle={{ color: 'white' }}
keyboardType={Platform.OS === 'web' ? 'default' : 'number-pad'}
returnKeyType="done"
/>
</View>
<BottomFixedCTA
ctaLabel={i18n.t('phone_send_code')}
loading={smsCodeIsBusy}
disabled={!isValid}
onPress={handleSubmit as undefined}
onBackPress={this._navSignUp}
/>
</View>
);
}}
/>
</ScrollView>
</KeyboardAvoidingView>
最佳答案
尝试使用:
<ScrollView keyboardShouldPersistTaps="handled">
关于typescript - 需要在 KeyboardAvoidingView 中单击两次,即使 Keyboardshouldpersisttaps 始终为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56067862/