gpt4 book ai didi

react-native - 使用 expo-splash-screen 的 react-native expo 错误 : No native splash screen registered for given view controller.

转载 作者:行者123 更新时间:2023-12-04 14:52:38 32 4
gpt4 key购买 nike

Unhandled promise rejection: Error: No native splash screen registered for given view controller. Call 'SplashScreen.show' for given view controller first.当我第一次启动应用程序时,我只在我的 ios 模拟器上收到以下警告。不在我的 ios 物理设备或 android 模拟器上。我正在使用 expo-splash-screen对于我的启动画面。这是我可以忽略的事情还是我需要解决它,因为我不知道如何解决它。启动画面似乎加载良好。 expo-splash-screen 是否有错误? ?我关注了 expo's tutorial在设置它。
警告:

[Unhandled promise rejection: Error: No native splash screen registered for given view controller. Call 'SplashScreen.show' for given view controller first.]
at node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:103:50 in promiseMethodWrapper
at node_modules/@unimodules/react-native-adapter/build/NativeModulesProxy.native.js:15:23 in moduleName.methodInfo.name
at node_modules/expo-splash-screen/build/SplashScreen.js:23:17 in hideAsync
at node_modules/expo-splash-screen/build/SplashScreen.js:19:7 in hideAsync
at [native code]:null in callFunctionReturnFlushedQueue
index.js
import React, { useState, useEffect, useCallback } from 'react';
import * as SplashScreen from 'expo-splash-screen';
import * as Font from 'expo-font';
import { Asset } from 'expo-asset';
import AppLoading from 'expo-app-loading';

import Navigation from './config/Navigation';

export default function App() {
const [appIsReady, setAppIsReady] = useState(false);

useEffect(() => {
async function prepare() {
try {
// keep splash screen visible while we fetch resources
await SplashScreen.preventAutoHideAsync();
// Pre-load fonts, make any api calls here
await Asset.loadAsync(require('../assets/IMG_0024.jpg'));
// Artificially delay for two seconds to simulate a slow loading
// experience. Please remove this if you copy and paste the code!
// await new Promise(resolve => setTimeout(resolve, 2000));
} catch (e) {
console.warn(e);
} finally {
// Tell app to render
setAppIsReady(true);
}
}

prepare();
}, []);

const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
// This tells the splash screen to hide immediately! If we call this after
// `setAppIsReady`, then we may see a blank screen while the app is
// loading its initial state and rendering its first pixels. So instead,
// we hide the splash screen once we know the root view has already
// performed layout.
await SplashScreen.hideAsync();
}
}, [appIsReady]);

onLayoutRootView();

if (!appIsReady) {
return <AppLoading />;
}

return <Navigation />;
}

app.json
{
"expo": {
"name": "name",
"slug": "slug",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#fffffb"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["assets/images/*"],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFB"
}
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}

最佳答案

问题是因为您使用的是 AppLoading ,此组件目前在 iOS 上存在此错误。
您可以解决这个问题,在错误解决之前避免使用此组件,另一种方法是创建一个类似于 Splashscreen 的 Screen 并替换 <AppLoading /><MyAwesomeSplashScreen />......或者以一种粗鲁和懒惰的方式 (糟糕的用户体验)刚换<AppLoading /><View />

关于react-native - 使用 expo-splash-screen 的 react-native expo 错误 : No native splash screen registered for given view controller.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68823075/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com