You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/10/29 10:06:16 UTC

[GitHub] lynnleelhl closed pull request #1662: [iOS] treat 750 as container width not device width when rotated or splited in ipad

lynnleelhl closed pull request #1662: [iOS] treat 750 as container width not device width when rotated or splited in ipad
URL: https://github.com/apache/incubator-weex/pull/1662
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/playground/WeexDemo/WXDemoViewController.m b/ios/playground/WeexDemo/WXDemoViewController.m
index 02959719aa..a016d10719 100644
--- a/ios/playground/WeexDemo/WXDemoViewController.m
+++ b/ios/playground/WeexDemo/WXDemoViewController.m
@@ -49,7 +49,7 @@ - (instancetype)init
 {
     if (self = [super init]) {
     }
-    
+
     return self;
 }
 
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h
index aa7e5a754f..a50eb5377a 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h
@@ -153,6 +153,8 @@ namespace WeexCore
                  isWidthWrapContent:(BOOL)isWidthWrapContent
                 isHeightWrapContent:(BOOL)isHeightWrapContent;
 
++ (void)setDeviceWidth:(CGFloat)width;
+
 + (void)setViewportWidth:(NSString*)pageId width:(CGFloat)width;
 
 + (void)layoutPage:(NSString*)pageId forced:(BOOL)forced;
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
index 41c5d80286..8f37a73f25 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
@@ -893,6 +893,10 @@ + (void)setDefaultDimensionIntoRoot:(NSString*)pageId width:(CGFloat)width heigh
     }
 }
 
++ (void)setDeviceWidth:(CGFloat)width {
+    WXCoreEnvironment::getInstance()->SetDeviceWidth(std::to_string(width));
+}
+
 + (void)setViewportWidth:(NSString*)pageId width:(CGFloat)width
 {
     if (platformBridge) {
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
index e22dc38d76..91967ae201 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
@@ -173,6 +173,7 @@ - (void)rootViewFrameDidChange:(CGRect)frame
 {
     WXAssertComponentThread();
     CGSize size = _weexInstance.frame.size;
+    [WXCoreBridge setDeviceWidth:size.width];
     [WXCoreBridge setDefaultDimensionIntoRoot:_weexInstance.instanceId
                                         width:size.width height:size.height
                            isWidthWrapContent:size.width == 0.0f isHeightWrapContent:size.height == 0.0f];
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
index 097e3798dc..2621b1d25b 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -731,7 +731,8 @@ + (NSString *)registeredDeviceName
 + (CGSize)portraitScreenSize
 {
     if ([[UIDevice currentDevice].model isEqualToString:@"iPad"]) {
-        return [UIScreen mainScreen].bounds.size;
+        CGRect windowRect = [UIApplication sharedApplication].keyWindow.bounds;
+        return windowRect.size;
     }
     static CGSize portraitScreenSize;
     static dispatch_once_t onceToken;
@@ -747,7 +748,8 @@ + (CGSize)portraitScreenSize
 + (CGFloat)defaultPixelScaleFactor
 {
     if ([[UIDevice currentDevice].model isEqualToString:@"iPad"]) {
-        return [self portraitScreenSize].width / WXDefaultScreenWidth;
+        CGRect windowRect = [UIApplication sharedApplication].keyWindow.bounds;
+        return windowRect.size.width / WXDefaultScreenWidth;
     }
     static CGFloat defaultScaleFactor;
     static dispatch_once_t onceToken;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services