使用react-native-splash-screen后iOS应用卡在启动页求助
解决react-native-splash-screen iOS启动页卡住的问题
核心问题:AppDelegate中[RNSplashScreen show]调用顺序错误
你的AppDelegate.m里,[RNSplashScreen show]在[super application:...]之前执行,这会导致React Native桥接还未初始化完成,SplashScreen无法正常接收后续的隐藏指令,最终卡在启动页。
修改后的AppDelegate.m代码
#import "AppDelegate.h" #import <React/RCTBundleURLProvider.h> #import "RNSplashScreen.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.moduleName = @"spengucomputer"; self.initialProps = @{}; // 先调用super完成RN桥接初始化 [super application:application didFinishLaunchingWithOptions:launchOptions]; // 再显示启动页 [RNSplashScreen show]; return YES; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif } @end
额外检查项
- 确认iOS项目已正确配置启动页资源(LaunchScreen.storyboard或LaunchImage),且
react-native-splash-screen已关联该资源 - 可简化App.js的启动页隐藏逻辑,直接在useEffect中调用
SplashScreen.hide(),避免定时器意外中断导致的问题:
import React, { useEffect } from 'react'; import Navigations from './src/Routes/Navigations'; import SplashScreen from 'react-native-splash-screen'; const App = () => { useEffect(() => { SplashScreen.hide(); }, []) return ( <Navigations /> ); } export default App;
- 确保已执行
pod install,且react-native-splash-screen的iOS模块已正确链接
内容的提问来源于stack exchange,提问作者Atul Singour
相关产品推荐
相关产品推荐

