KeyboardAvoidingView或替代品

时间:2017-07-16 11:52:05

标签: reactjs react-native redux-form expo

我试图阻止键盘阻止iOS上的输入,我意识到使用android我可以做类似设置android:windowSoftInputMode =" adjustPan"在你的清单文件中实现这一点。

但是我遇到了一些问题:

  • KeyboardAvoidingView似乎不适用于redux-form
  • 项目目前正在上世博会,大概要分开做adjustPan。有没有像我可以使用的库那样的替代品?

我尝试过:

<Form>
<KeyboardAvoidingView
behavior="padding" >
<FieldsContainer>
<Fieldset label = "Edit Profile">

  <Input name = "name"
  label = "Name"
  placeholder = "Jane Doe" />

  <Select
  name = "gender"
  label = "Gender"
  options = {genderOptions}
  placeholder = "Male"
  />

  <Select
  name="bodyType"
  label="Body Type"
  options={bodyTypeOptions}
  placeholder="Mesomorph"
  />

  <Select
  name = "location"
  label = "Location"
  options = {locationOptions}
  placeholder = "Central"
  />

  <Input name="bio" label="Bio" placeholder="" multiline={true} numberOfLines={3}  inlineLabel={false} />


</Fieldset>

</FieldsContainer>
</KeyboardAvoidingView>

<ActionSheetContainer />

  <Button
  onPress={handleSubmit(this.submit.bind(this))}
  > Submit </Button>

  <SuccessMessage
  success = {submitSucceeded} />

</Form>

视图根本不滚动。

1 个答案:

答案 0 :(得分:0)

您可以尝试react-native-keyboard-aware-scroll-view

import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'

<KeyboardAwareScrollView>
  <View>
    <TextInput />
  </View>
</KeyboardAwareScrollView>