为什么在“ standaloneApp(Expo弹出)”和React-native上看不到启动屏幕?

时间:2019-05-30 01:22:19

标签: android react-native react-native-android expo react-native-ios

我正在使用Expo制作应用。

但是我确实独立使用expo eject来使用基本模块。

我想看到一个基本的启动屏幕,以及我制作的启动屏幕。

我已经知道可以在Android Studio中制作splashScreen。

我不能在app.json上设置启动屏幕吗?

我的App.json

{
  "expo": {
    "name": "mvw",
    "description": "This project is really great.",
    "slug": "test",
    "privacy": "public",
    "sdkVersion": "30.0.0",
    "packagerOpts": {
      "config": "./rn-cli.config.js"
    },
    "platforms": ["android"],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "android": {
      "package": "com.jackson.myapp",
      "publishBundlePath": "android/app/src/main/assets/shell-app.bundle",
      "publishManifestPath": "android/app/src/main/assets/shell-app-manifest.json",
      "splash": {
        "backgroundColor": "black",
        "resizeMode": "contain",
        "mdpi": "./image/splash.png",
        "hdpi": "./image/splash@2x.png",
        "xhdpi": "./image/splash@3x.png",
        "xxhdpi": "./image/splash@4x.png",
        "xxxhdpi": "./image/splash@5x.png"
      }
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true,
      "usesIcloudStorage": true,
      "bundleIdentifier": "com.jackson.myapps",
      "publishBundlePath": "ios/mvw/Supporting/shell-app.bundle",
      "publishManifestPath": "ios/mvw/Supporting/shell-app-manifest.json"
    },
    "isDetached": true,
    "detach": {
      "iosExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/ios-v2.8.4-sdk30.0.0-3de13133-1adc-4ba1-8569-a84011e570b4.tar.gz",
      "androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v2.8.1-sdk30.0.0-0fde103b-be3d-43f9-bc48-3035aa136971.tar.gz"
    },
    "scheme": "exp6c94a01048724a76bc92dca0c0cdd24a"
  }
}

App.js

import React, { Component } from "react";
import HomeScreen from "./screen/HomeScreen";
import { Image, View, Platform } from "react-native";
import { Asset, SplashScreen, AppLoading } from "expo";

export default class AwesomeApp extends Component {
  constructor(props) {
    super(props);
    SplashScreen.hide();
    this.state = {
      isReady: false
    };
  }

  async componentDidMount() {
    this.cacheResourcesAsync() // ask for resources
      .then(() => this.setState({ areReasourcesReady: true })) // mark reasources as loaded
      .catch(error =>
        console.error(`Unexpected error thrown when loading:
${error.stack}`)
      );
    await Expo.Font.loadAsync({
      Roboto: require("native-base/Fonts/Roboto.ttf"),
      Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
      Ionicons: require("native-base/Fonts/Ionicons.ttf")
    });
  }

  async cacheResourcesAsync() {
    const images = [require("./image/splash.png")];
    const cacheImages = images.map(image =>
      Asset.fromModule(image).downloadAsync()
    );
    return Promise.all(cacheImages);
  }

  render() {
    if (!this.state.areReasourcesReady) {
      return (
        <View
          style={{ flex: 1, justifyContent: "center", alignItems: "center" }}
        >
          <Image
            source={require("./image/splash.png")}
            onLoad={this._cacheResourcesAsync}
          />
        </View>
      );
    }
    return <HomeScreen />;
  }
}
  

现在我看不到basic splash screen,我可以看到screen I made一会儿,然后才能看到home screen

请给我们很多解决方案和帮助。预先谢谢你。

如果此问题仍未解决,则在移动初始屏幕时必须查看初始屏幕。

0 个答案:

没有答案