简体   繁体   English

使用 KeyboardAvoidingView 作为父级反应 Native ViewPager 不会保持键盘向上 - iOS

[英]React Native ViewPager with a KeyboardAvoidingView as parent doesn't keep the keyboard up - iOS

When I use the ViewPager from react-native-community/viewpager with a KeyboardAvoidingView and the style of ViewPager is flex:1 and the behaviour of KeyboardAvoidingView is padding the keyboard can't keep up.当我使用react-native-community/viewpager中的ViewPagerKeyboardAvoidingView并且ViewPager的样式是flex:1并且 KeyboardAvoidingView 的行为是padding键盘无法跟上时。

<KeyboardAvoidingView style={{flex: 1}} behavior="padding">
    <ViewPager
      {...viewPagerProps}
      ref={viewPagerRef}
      scrollEnabled={false}
      keyboardDismissMode="on-drag"
      style={[{flex: 1, borderWidth: 1, borderColor: 'red'}, style]}
      onPageScroll={Animated.forkEvent(onPageScroll, _onPageScroll)}
    />
    {_renderBottomControls()}
  </KeyboardAvoidingView>

_renderBottomControls() _renderBottomControls()

<SafeAreaView style={{flexDirection: 'row', justifyContent: 'space-between', padding: 8}}>
    <Transitioning.View
      transition={transition}
      ref={transitionBackButtonRef}>
      {currentPage !== 0 && (
        <Button mode="text" compact onPress={_onPressPrevious}>
          Voltar
        </Button>
      )}
    </Transitioning.View>

    <Button mode="contained" disabled={!isValid} onPress={_onPressNext}>
      {isLastPage ? 'Concluir' : 'Continuar'}
    </Button>
  </SafeAreaView>

GIF 显示问题

The fix for this was not obvious and I hope the developers will put this in the documentation对此的修复并不明显,我希望开发人员将其放入文档中

The view pager needs to be position absolute视图寻呼机需要是 position 绝对

<ViewPager style={{position: 'absolute'}}/>

Also if the screen is now being hiden by the keyboard, wrap the viewpager in a KeyboardAvoidingView此外,如果屏幕现在被键盘隐藏,请将 viewpager 包装在KeyboardAvoidingView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM