[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] Support change device width and height by external interface.
Browse files Browse the repository at this point in the history
* feature: used on landscape started apps.
  • Loading branch information
huanglei.hl committed Mar 28, 2019
1 parent 36dce32 commit 02dfe22
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ namespace WeexCore

+ (void)setViewportWidth:(NSString*)pageId width:(CGFloat)width;

+ (void)setPageRequired:(NSString *)pageId width:(CGFloat)width height:(CGFloat)height;

+ (void)layoutPage:(NSString*)pageId forced:(BOOL)forced;

+ (void)closePage:(NSString*)pageId;
Expand Down
8 changes: 8 additions & 0 deletions ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,14 @@ + (void)setViewportWidth:(NSString*)pageId width:(CGFloat)width
}
}

+ (void)setPageRequired:(NSString *)pageId width:(CGFloat)width height:(CGFloat)height
{
/// Because env is global, pageId is not used now time.
WeexCore::WXCoreEnvironment* env = WeexCore::WXCoreEnvironment::getInstance();
env->SetDeviceWidth(std::to_string(width));
env->SetDeviceHeight(std::to_string(height));
}

+ (void)layoutPage:(NSString*)pageId forced:(BOOL)forced
{
if (platformBridge) {
Expand Down
5 changes: 4 additions & 1 deletion ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ typedef NS_ENUM(NSInteger, WXErrorCode) {//error.code

@property (nonatomic ,strong) WXApmForInstance* apmInstance;


/**
* Application required Page Width and Height to prevent Weex use DeviceWidth directly.
*/
- (void)setPageRequiredWidth:(CGFloat)width height:(CGFloat)height;

/**
* Deprecated
Expand Down
5 changes: 5 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ - (void)setViewportWidth:(CGFloat)viewportWidth
[WXCoreBridge setViewportWidth:_instanceId width:viewportWidth];
}

- (void)setPageRequiredWidth:(CGFloat)width height:(CGFloat)height
{
[WXCoreBridge setPageRequired:_instanceId width:width height:height];
}

- (void)renderWithURL:(NSURL *)url
{
[self renderWithURL:url options:nil data:nil];
Expand Down

0 comments on commit 02dfe22

Please sign in to comment.