Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onLayout works differently in iPhone and iPad simulators #7504

Closed
anttitakalahti opened this issue May 11, 2016 · 5 comments
Closed

onLayout works differently in iPhone and iPad simulators #7504

anttitakalahti opened this issue May 11, 2016 · 5 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@anttitakalahti
Copy link

This might be an issue with the xCode but I am getting strange values for Dimensions.get('window'). In iPhone simulator it works as expected and shows the new values for height and width but using iPad simulator (iPad Air 2 and iPad Pro) I get the old height and width. This results in broken views as I try to fit the login screen to full page using margin for status bar and calculating the height of the keyboard.

@radko93
Copy link
Contributor

radko93 commented May 11, 2016

This was also reported here #7340. I'm going to test this on iOS now.

@radko93
Copy link
Contributor

radko93 commented May 11, 2016

I've made a little research and it seems to be a iOS behaviour (bug). Made an empty app and with this code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[NSNotificationCenter defaultCenter] 
         addObserver: self 
         selector: @selector(deviceOrientationDidChange:) 
         name: UIDeviceOrientationDidChangeNotification object: nil];

    return YES;
}

- (void)deviceOrientationDidChange:(NSNotification *)notification {
    // using this statusBarOrientation since code in RN repo is depreciated in iOS8
    NSLog(@"%ld", (long)[[UIApplication sharedApplication] statusBarOrientation]);
}

From my tests:

  • iPhone is fine
  • iPad:
2016-05-11 14:50:28.498 Playground iOS[66600:4777507] 1 // on startup
2016-05-11 14:50:33.097 Playground iOS[66600:4777507] 1 // after screen rotation from portrait to landscape
2016-05-11 14:50:42.946 Playground iOS[66600:4777507] 3 // back from landscape to initial portrait orientation
2016-05-11 14:50:44.542 Playground iOS[66600:4777507] 1 // back from landscape

So it seems the first orientation change is not being set properly.

Tested on XCode 7.3, iPhone and iPad both simulators.

@ghuh
Copy link

ghuh commented Jun 12, 2016

Note that, for #7340, I tested this on a physical iPhone 6s and a physical iPad Air 2 and got the same behavior so this is not just a simulator issue.

@mkonicek
Copy link
Contributor

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/onlayout-works-differently-in-iphone-and-ipad-simulators

Product Pains has been very useful in highlighting the top bugs and feature requests:
https://productpains.com/product/react-native?tab=top

Also, if this issue is a bug, please consider sending a pull request with a fix.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 19, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants
@mkonicek @anttitakalahti @radko93 @ghuh @react-native-bot and others