提问人:Atul Singour 提问时间:9/13/2023 更新时间:9/13/2023 访问量:31
Splashscreen.hide() 在 ios 设备中不起作用
Splashscreen.hide() is not working in ios device
问:
我正在使用 react-native-splash-screen 库,Splashscreen.hide() 在 android 设备上正常工作,但它在 ios 设备中不起作用,因为启动屏幕没有隐藏。
这是我的 appdelegate 文件
#import <Firebase.h>
#import "AppDelegate.h"
#import "RNSplashScreen.h" // here
#import <React/RCTBundleURLProvider.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
self.moduleName = @"spengucomputercourse";
// 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]; // here
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
这是我的 app.js 文件,我在其中使用 hide 函数
import React, {useEffect} from 'react';
import Navigations from './src/Routes/Navigations';
import SplashScreen from 'react-native-splash-screen';
import {LogBox} from 'react-native';
const App = () => {
LogBox.ignoreAllLogs();
useEffect(() => {
SplashScreen.hide();
}, []);
return <Navigations />;
};
答:
1赞
jonnathan diaz cubides
9/13/2023
#1
可能是由于react-native的版本,我遇到了同样的问题,这个链接帮助我在这里输入了链接描述
例:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleName = @"testApp";
// 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;
}
评论
0赞
Atul Singour
9/28/2023
谢谢,现在它工作正常。您的帮助是可观的。
评论