0

我已经看到了很多与此问题相关的问题,但到目前为止我无法解决问题。以下问题仅发生在 iOS 设备中。

我已经在 TouchableOpacity 按钮中使用“tcomb-form-native”库实现了一个表单。问题是当任何输入聚焦时保存按钮是不可点击的。这意味着我必须点击两次来保存我的表单,一次是为了删除/失去对输入的关注,一次是最后点击我的保存表单按钮。

我正在使用KeyboardAvoidingView来解决与 iOS 的兼容性问题。我也尝试过处理和始终使用keyboardShouldPersistTaps 。与 Keyboard.dismiss() 函数相同。对于任何情况,结果都相同。

这是我的代码:

 render() {
    const keyboardVerticalOffset = Platform.OS === "ios" ? 40 : 0;

    return (
      <KeyboardAvoidingView
        behavior={Platform.OS === "ios" ? "padding" : ""}
        keyboardVerticalOffset={keyboardVerticalOffset}
        style={styles.container}
      >
        <View
          style={{
            flexDirection: "column",
            justifyContent: "space-between",
            height: "100%",
            backgroundColor: colors.white,
          }}
        >
          <ScrollView
            ref={(scroll) => (this.scroll = scroll)}
            keyboardShouldPersistTaps={'handled'}
            style={{
              marginBottom: this.state.marginBottom,
              paddingHorizontal: 20,
            }}
          >
            <DateForm
              onChangeDate={this.onChangeDate.bind(this)}
              date={this.state.measureDate}
              birthdate={this.state.baby.Birthdate}
            />
            <MeasureForm
              onChangeMeasure={this.onChangeValue.bind(this)}
              value={this.state.value}
              scrollTo={this.scrollTo.bind(this)}
            />
            <ResultsForm
              IC={this.state.indexes.IC}
              IABC={this.state.indexes.IABC}
              colorIC={this.state.indexes.colorIC}
              colorIABC={this.state.indexes.colorIABC}
            />

            <CBButton
              title={global.loc.getTranslation("AddMeasureSaveButton")}
              style={{
                width: "100%",
                marginHorizontal: 0,
                flexGrow: 1,
                marginTop: 20,
                marginBottom: 50,
              }}
              disabled={!this.state.validForm}
              onPress={() => this.disableButton()}
            />
          </ScrollView>
        </View>
      </KeyboardAvoidingView>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});
4

0 回答 0