Comments (6)
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.
Awesome, thanks.
from react-native-device-display.
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.
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.
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.
Merged. #16
from react-native-device-display.
Related Issues (17)
- React Native Android Support HOT 8
- If the device is landscape when app start, all value is opposite. HOT 6
- Flipping Around Breaks This HOT 1
- Seems to be incompatible with React Native 0.14.x and 0.13.x HOT 6
- Submitting a pull request HOT 1
- [UIScreen applicationFrame] is deprecated on iOS 9.0
- Potential bug in the JS orientation predicates
- UI Error Message after upgrading to React Native 0.7.1 HOT 3
- Is orientation worked for a build product-apk HOT 1
- NPM Updates on Dimensions import issue HOT 1
- Doesnot it support on android? HOT 1
- Missing tag for master HOT 1
- Unlisten to Display.onOrientationDidChange HOT 4
- Support newest versions of React Native HOT 4
- GPL - Incompatible with iOS App Store HOT 1
- Need to change API for onOrientationDidChange HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-device-display.