【问题标题】:Why Dimensions.get('window').height returns 0 on iOS?为什么Dimensions.get('window').height 在iOS 上返回0?
【发布时间】:2019-12-04 15:08:11
【问题描述】:

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

但是Dimensions.get('screen').height = something

为什么会这样?

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】:

已修复。这是AppDelegate.m RNSplashScreen 的问题。

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;
}

【讨论】:

    猜你喜欢
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 2013-04-22
    • 2012-05-21
    • 2014-10-31
    • 1970-01-01
    • 2013-10-08
    • 2013-01-08
    相关资源
    最近更新 更多