You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 18:03:43