【发布时间】:2019-09-27 18:55:04
【问题描述】:
我正在使用 KeyboardAvoidingView 来使用键盘向上移动按钮,其中我有一个滚动视图,其中 keybordShouldPersistTaps 设置为始终,在滚动视图中,我使用的是 Formik 表单。我仍然需要双击一个按钮两次才能让键盘关闭并提交我的数据。我一直试图手动关闭/处理滚动视图上的键盘,但没有运气,我应该尝试其他方法吗?
<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>
【问题讨论】:
标签: typescript react-native formik