简体   繁体   English

React Native - 模态不会在 IOS 上打开

[英]React Native - Modal doesn't open on IOS

I have the following Modal.我有以下模态。 On Android everthing works perfect but on IOS the modal doesn't open at all.在 Android 上一切正常,但在 IOS 上,模式根本没有打开。 It just shows the overlay on the half of the screen and that's it.它只是在屏幕的一半上显示叠加层,仅此而已。 Can you please check the following implementation?你能检查一下下面的实现吗?

For this implementation I have use the following library that is inside the react-native library https://reactnative.dev/docs/modal对于这个实现,我使用了 react-native 库https://reactnative.dev/docs/modal中的以下库

<Modal animationType={FADE_ANIMATION_TYPE} transparent={true} visible={isVisible}>
            <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={{ flex: 1 }}>
              <View style={style.outerContainer}>
                <View style={style.innerConainer}>
                  <View style={style.topConainer}>
                    <View>
                      <Text>{title}</Text>
                    </View>
                    <View style={style.cancel}>
                      <TouchableWithoutFeedback onPress={cancel}>
                        <Ionicons name={'close-outline'} size={24} color={red} />
                      </TouchableWithoutFeedback>
                    </View>
                  </View>
                  <View style={style.contentContainer}>
                    <View style={style.subject}>
                      <Text style={style.label}>Title</Text>
                      <TextInput
                        style={style.textInput}
                        onChangeText={text => setText(text)}
                        placeholderTextColor={'blue'}
                      />
                    </View>
                    <View style={style.comment}>
                      <View style={style.header}>
                        <Text>Message:</Text>
                        <Text>{addingComment}</Text>
                      </View>
                      <TextInput
                        style={style.textInput}
                        placeholderTextColor={blueText}
                        onChangeText={text => setComment(text)}
                        maxLength={1024}
                        multiline={true}
                      />
                    </View>
                  </View>
                  <Button
                    title='Send'
                    onPress={onSendPress}
                    disabled='fasle'
                  />
                </View>
              </View>
            </KeyboardAvoidingView>
          </Modal>

The styles: styles:

export default StyleSheet.create({
  outerContainer: {
    backgroundColor: '#808080',
    flex: 1,
    justifyContent: 'space-evenly',
  },
  container: {
    backgroundColor: '#808080',
    paddingVertical: 20,
    flexDirection: 'column',
    position: 'absolute',
    bottom: height / 2.5,
    width: '95%',
    alignItems: 'center',
    height: height / 6,
    borderRadius: 15,
    zIndex: 800,
  },
  innerConainer: {
    backgroundColor: '#808080',
    paddingVertical: 10,
    flexDirection: 'column',
    position: 'absolute',
    bottom: 0,
    width: '100%',
    alignItems: 'center',
    height: height / 2,
    borderRadius: 20,
    zIndex: 800,
  },
  topContainer: {
    flexDirection: 'row',
    flex: 1,
    justifyContent: 'space-between',
    width: '100%',
    paddingHorizontal: 15,
    paddingVertical: 13,
    flexWrap: 'wrap',
  },
  cancel: {
    height: 100,
  },
  buttonsContainer: {
    flex: 2,
    flexDirection: 'row',
  },
  contentContainer: {
    width: '100%',
    backgroundColor: '#f7f8ff',
    borderTopLeftRadius: 10,
    borderTopRightRadius: 10,
    flex: 8,
  },
  comment: {
    padding: 10,
    margin: 17,
    backgroundColor: white,
    height: 85,
  },
  header: {
    display: 'flex',
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  textInput: {
    marginRight: 1,
    marginTop: 5,
  },

});

Try this modal package .试试这个模式 package And also this package supports native drive which gives your app performance.此外,这款 package 支持本机驱动,可为您的应用提供性能。

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

相关问题 flutter:SFSafariViewController 无法像原生 iOS 模态一样打开 - flutter: SFSafariViewController doesn't open like a native iOS modal React 本机项目不运行 iOS - React native project doesn't run iOS Google Place Picker无法打开(本地ios应用程序) - google place picker doesn't open (react-native ios application) iOS React Native-使用本机代码导航不起作用 - iOS React Native - navigation doesn't work using native code 无法使用React Native在iOS中打开共享对话框 - Can't open the share dialog in iOS with React Native 当 iOS 登录模式打开时出现异常“评估 textInputRef.isFocuded”,在应用程序购买中反应本机 - Exception "evaluating textInputRef.isFocuded" when iOS SignIn modal is open, react native in app purchases 反应本机运行ios构建成功,但未显示 - react native run ios build succeeded but it's doesn't show react-native-push-notification 在 ios 设备上不起作用 - react-native-push-notification doesn't work on ios DEVICE react-native-webview 不会改变 iOS 上的屏幕方向 - react-native-webview doesn't change screen orientation on iOS React Native 应用程序不会在 IOS 版本 11 和 12 上加载 - React Native app doesn't load on IOS versions 11 and 12
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM