Fixed screen size bug on iPhone6+

Summary:
public

This diff fixes a bug in RCTScreenScale() on iPhone6+. The issue was due to the fact that the iPhone6+'s virtual screen resolution of 414x736 points 3x resolution (1242x2208 pixels) does not match its actual screen resolution, which is 1080p (1080x1920 pixels).

I did not realize that `[UIScreen mainScreen].nativeBounds` reports the *actual* resolution, not the virtual resolution, and was dividing by the virtual scale (3.0) instead of the actual native scale factor (2.6).

This only affects iPhone6+, because for all other iOS devices, the virtual resolution matches the native resolution.

Reviewed By: milend

Differential Revision: D2854663

fb-gh-sync-id: bce8965a151e2f005a02a5f6b54f259d01b9ab12
This commit is contained in:
Nick Lockwood 2016-01-22 08:18:15 -08:00 committed by facebook-github-bot-3
parent c4b948f62e
commit 36e0dd2d48
1 changed files with 1 additions and 7 deletions

View File

@ -219,13 +219,7 @@ CGSize RCTScreenSize()
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
RCTExecuteOnMainThread(^{
if ([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedDescending) {
CGSize pixelSize = [UIScreen mainScreen].nativeBounds.size;
CGFloat scale = RCTScreenScale();
size = (CGSize){pixelSize.width / scale, pixelSize.height / scale};
} else {
size = [UIScreen mainScreen].bounds.size;
}
}, YES);
});