为什么Dimensions.get('window')。height在iOS上返回0?

问题描述 投票:0回答:1

对于iOS:Dimensions.get('window')。height = 0

但是Dimensions.get('screen')。height =某物

为什么可以?

console.log('DIMENSIONS', Dimensions.get('window'), Dimensions.get('screen'));


// logs
window = {fontScale: 1, height: 0, width: 0, scale: 2} 
screen = {fontScale: 1, height: 896, width: 414, scale: 2}
react-native platform
1个回答
0
投票

已修复。 RNSplashScreen在AppDelegate.m中存在问题。

https://github.com/crazycodeboy/react-native-splash-screen#third-stepplugin-configuration

问题代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [RNSplashScreen show]; // here

    // ...other code
    return YES;
}

工作:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // ...other code

    [RNSplashScreen show];  // here
    // or
    //[RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];
    return YES;
}
© www.soinside.com 2019 - 2024. All rights reserved.