Ios 在react native中关闭父组件时,有没有办法不关闭键盘

Ios 在react native中关闭父组件时,有没有办法不关闭键盘,ios,react-native,keyboard,expo,Ios,React Native,Keyboard,Expo,当前,只要父组件或模式可见,我就会自动打开键盘,这正是我想要的,但问题是,当我首先关闭模式时,键盘将被关闭,然后模式将被关闭,这将导致糟糕的UI交互。我想让键盘保持静止,只关闭父组件或模态,而不是两者。我在键盘内使用scrollView AvoidingView,而键盘应将PersistTaps设置为“始终”。您可以在下面找到我的代码: const amountInput = () => ( <View style={styles.inputAndTextContai

当前,只要父组件或模式可见,我就会自动打开键盘,这正是我想要的,但问题是,当我首先关闭模式时,键盘将被关闭,然后模式将被关闭,这将导致糟糕的UI交互。我想让键盘保持静止,只关闭父组件或模态,而不是两者。我在键盘内使用scrollView AvoidingView,而键盘应将PersistTaps设置为“始终”。您可以在下面找到我的代码:

    const amountInput = () => (
    <View style={styles.inputAndTextContainer}>
      <Text style={styles.textStyle}>ETB</Text>
      <TextInput
        onKeyPress={({ nativeEvent }) => {
          return nativeEvent.key === 'Backspace' ? clearLastChar() : null;
        }}
        caretHidden
        ref={textInputRef}
        style={styles.inputStyle}
        autoCapitalize="none"
        autoCorrect={false}
        keyboardType="numeric"
        defaultValue={amount.value}
        /* value={amount.value} */
        autoFocus
        maxLength={6}
        onChangeText={num => {
          setAmount({ value: addCommaToNumber(num) });
        }}
      />
    </View>
  );

   return (
    <View>
      <Modal
        isVisible={isVisible}
        animationIn="bounceInUp"
        animationOut="slideOutDown"
        animationOutTiming={200}
        animationInTiming={200}
        style={{ margin: 0 }}
      >
        <KeyboardAvoidingView behavior="padding">
          <Header />
          <ScrollView
            keyboardShouldPersistTaps="always"
            alwaysBounceVertical={false}
          >
            {amountInput()}
            {state && state.length ? someFunc() : anotherFunc()}
          </ScrollView>

          {renderModal()}
          {state ? someFunc() : someotherfunc()}
        </KeyboardAvoidingView>
      </Modal>
    </View>
    )
const amountInput=()=>(
ETB
{
return nativeEvent.key=='Backspace'?clearLastChar():null;
}}
卡里蒂登
ref={textInputRef}
style={styles.inputStyle}
autoCapitalize=“无”
自动更正={false}
keyboardType=“数字”
defaultValue={amount.value}
/*value={amount.value}*/
自动对焦
maxLength={6}
onChangeText={num=>{
setAmount({value:addCommatNumber(num)});
}}
/>
);
返回(
{amountInput()}
{state&&state.length?someFunc():anotherFunc()}
{renderModal()}
{state?someFunc():someotherfunc()}
)