我正在使用 React Native 开发一个应用程序,并尝试在 ios 上添加启动屏幕。我在 AppDelegate.mm 上添加了以下代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleName = @"eCare";
// 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]; //Added this line
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
此后我的应用程序卡在启动屏幕中。我将启动屏幕隐藏在 React Native 的根屏幕上。我按照官方指南这里
我查看了库的doc,发现您的 AppDelegate 代码有所不同。看到方法最后
didFinishLaunchWithOptions
有一个return YES
,尝试用这个代替 return [super application:application didFinishLaunchingWithOptions:launchOptions];
,看看是否有效。如果它不起作用,请回答,以便我们尝试找到另一个答案。
切换返回 [超级应用程序:application didFinishLaunchingWithOptions:launchOptions];
与以下...
bool didFinish=[超级应用程序:应用程序didFinishLaunchingWithOptions:launchOptions];
[RNSplashScreen 显示]; // 这里返回 didFinish;
#import "RNSplashScreen.h" // At top
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleName = @"abc";
// 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 = @{};
// Add these lines ----------------
[super application:application didFinishLaunchingWithOptions:launchOptions];
[RNSplashScreen show];
return true;
}