This is an automated email from the ASF dual-hosted git repository. moshen pushed a commit to branch fix-device-portrait in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
commit b77f9e7fbaff12d6f900ee70ab482cda201e7dfc Author: qianyuan.wqy <[email protected]> AuthorDate: Mon Sep 16 11:04:45 2019 +0800 Initialize weex using portrait screen size. --- ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm index 44cd38b..fb3a03c 100644 --- a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm +++ b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm @@ -1538,11 +1538,14 @@ static WeexCore::ScriptBridge* jsBridge = nullptr; env->AddOption("scale", "1"); env->AddOption("pixel_scale", std::to_string([[UIScreen mainScreen] scale])); + // Here we initialize weex device width and height using portrait by default. CGSize screenSize = [UIScreen mainScreen].bounds.size; - env->SetDeviceWidth(std::to_string(screenSize.width)); - env->SetDeviceHeight(std::to_string(screenSize.height)); - env->AddOption("screen_width_pixels", std::to_string(screenSize.width)); - env->AddOption("screen_height_pixels", std::to_string(screenSize.height)); + CGFloat w = MIN(screenSize.width, screenSize.height); + CGFloat h = MAX(screenSize.width, screenSize.height); + env->SetDeviceWidth(std::to_string(w)); + env->SetDeviceHeight(std::to_string(h)); + env->AddOption("screen_width_pixels", std::to_string(w)); + env->AddOption("screen_height_pixels", std::to_string(h)); weex::base::LogImplement::getLog()->setLogImplement(new WeexCore::LogBridgeIOS()); @@ -1552,8 +1555,6 @@ static WeexCore::ScriptBridge* jsBridge = nullptr; weex::base::LogImplement::getLog()->setDebugMode(false); #endif - - platformBridge = new WeexCore::PlatformBridge(); platformBridge->set_platform_side(new WeexCore::IOSSide()); platformBridge->set_core_side(new WeexCore::CoreSideInPlatform());
