代码之家  ›  专栏  ›  技术社区  ›  AmerllicA

React native启动屏幕在React native 0.71上不起作用+

  •  0
  • AmerllicA  · 技术社区  · 3 年前

    通过使用 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);
    
    1 回复  |  直到 3 年前
        1
  •  1
  •   AmerllicA    3 年前

    在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

        2
  •  1
  •   вадим кудельский    3 年前

    我通过修改我的ApDelegate.mm文件来修复此问题 从…起

       // 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 = @{};
     [RNSplashScreen show]; 
      return [super application:application didFinishLaunchingWithOptions:launchOptions];
     
    }

    到

     self.initialProps = @{};
      [super application: applicationdidFinishLaunchingWithOptions:launchOptions];
      [RNSplashScreen show]; 
      return YES;
    推荐文章