【问题标题】:React native splash screen doesn't work on react-native 0.71+React Native 启动画面不适用于 React-Native 0.71+
【发布时间】:2023-02-21 08:26:26
【问题描述】:

通过使用Splash screen 文档,无法使启动画面消失。该应用程序卡在了显示启动画面的后面。

iOS 原生代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"ttttapp";
  
 [RNSplashScreen show];

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

安卓本机代码:

public class MainActivity extends ReactActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    androidx.core.splashscreen.SplashScreen.installSplashScreen(this);
    org.devio.rn.splashscreen.SplashScreen.show(this, true);
    super.onCreate(savedInstanceState);

【问题讨论】:

    标签: android ios react-native splash-screen


    【解决方案1】:

    在 iOS AppDelegate.m 文件中,它应该如下所示:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {  
      self.moduleName = @"ProjectName";
      // You can add your custom initial props in the dictionary below.
      // They will be passed down to the ViewController used by React Native.
      self.initialProps = @{};
      
      bool didFinish=[super application:application didFinishLaunchingWithOptions:launchOptions];
      
      [RNSplashScreen show];  // here
      return didFinish;
    }
    

    在 Android MainActivity.java 文件应该是这样的:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      SplashScreen.show(this);
      super.onCreate(savedInstanceState);
    }
    

    参考:issue#606

    【讨论】:

      猜你喜欢
      • 2020-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-27
      • 1970-01-01
      • 2018-11-20
      • 2017-10-20
      相关资源
      最近更新 更多