小编Jon*_*ell的帖子

React Native/Expo:当“visible”属性在 iOS 上为 true 时,模态不显示

我有一个在 React Native 中构建的应用程序,其中有一个模式,当按下按钮时会出现该模式并提示用户输入。我在应用程序中制作了其他模态,使用我现在使用的相同方法可以正常工作。但是,当我更改此模式的状态(确定模式是否可见)时,它似乎完全忽略它并且不显示。该模式适用于我的 Android 和我的许多 Android 模拟器,但由于某种原因它不适用于我的 iphone 10。

我有一个文件 GameScreen.js,它是屏幕组件,并在其中保存模式。它还保存模式可见性的相关方法和状态:

import { 
    Body, 
    Button, 
    Container, 
    Content, 
    Header, 
    Icon, 
    Left,  
    Right,  
    View } from 'native-base';
import { BackHandler, StyleSheet, Text, TextInput, TouchableOpacity, Platform } from 'react-native';
import React, { Component, createRef } from 'react';

import myModal from '../components/myModal';

export default class GameScreen extends Component {
  constructor(props) {
    super(props)

    this.state = { 
      // other state
      isVisible: false,
    }
    this.displayModal = this.displayModal.bind(this);
  }

  displayModal(show) {
    this.setState({
      isVisible: show
    })
  }

  render() …
Run Code Online (Sandbox Code Playgroud)

ios react-native expo

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

expo ×1

ios ×1

react-native ×1