Git Product home page Git Product logo

Comments (6)

eliagrady avatar eliagrady commented on May 26, 2024

Tried your fix - worked like a charm! Thank you!
I've made a pull request to the repo with your suggested changes, so everyone can enjoy your fix!

from react-native-device-display.

 avatar commented on May 26, 2024

Awesome, thanks.

from react-native-device-display.

0x0ece avatar 0x0ece commented on May 26, 2024

Hi, I've tried master (as these changes aren't versioned yet) and it works fine when I develop and reload the app, but not on when I launch the app for the first time.

I can't really figure out what the issue is, it appears that [UIScreen mainScreen].applicationFrame returns the wrong data (and now I understand the crazy swap of width and height).

However, googling around, it seems that UIDeviceOrientationDidChangeNotification is deprecated in favor of viewWillTransitionToSize:
http://stackoverflow.com/questions/26069874/what-is-the-right-way-to-handle-orientation-changes-in-ios-8
Maybe it's worth exploring the new style?

from react-native-device-display.

0x0ece avatar 0x0ece commented on May 26, 2024

Hi again,

I did additional tests, and I believe that viewWillTransitionToSize is the right way to go. It also works on slide over (multitasking) on ipad/ios9.

All I did to test is to implement a viewcontroller, and use it in my AppDelegate:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
  UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];
  NSDictionary *dimensions = @{ @"width": @(size.width), @"height": @(size.height), @"orientation": @(deviceOrientation) };

  NSLog(@"%@", dimensions);

  [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}

Unfortunately I have no idea how to send an event to js, here I need your help :)

from react-native-device-display.

0x0ece avatar 0x0ece commented on May 26, 2024

Last comment for today, promised. I made it work with a hack: I created the controller, sent a notification, and used this module to listen to my own notification instead of UIDeviceOrientationDidChangeNotification.

I asked on SO, if I can find a better/cleaner solution, I'll post a PR:
http://stackoverflow.com/questions/33469009/implement-native-controller-in-react-native

from react-native-device-display.

kkjdaniel avatar kkjdaniel commented on May 26, 2024

Merged. #16

from react-native-device-display.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.