diff --git a/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.m b/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.m index be31b044..14ad333d 100644 --- a/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.m +++ b/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.m @@ -14,6 +14,8 @@ #import "ThemeColor.h" #import "TTPopup.h" @interface XPRoomHalfWebView () +///容器 +@property (nonatomic,strong) UIStackView *stackView; ///点击消失的view @property (nonatomic,strong) UIView * topView; /// 导航栏 @@ -29,6 +31,10 @@ @end @implementation XPRoomHalfWebView +- (void)dealloc { + +} + - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; @@ -43,11 +49,22 @@ - (void)initSubViews { [self addSubview:self.topView]; - [self addSubview:self.toolView]; - [self addSubview:self.webVC.view]; + [self addSubview:self.stackView]; + + [self.stackView addArrangedSubview:self.toolView]; + [self.stackView addArrangedSubview:self.webVC.view]; [self.toolView addSubview:self.backButton]; [self.toolView addSubview:self.titleLabel]; + @kWeakify(self); + self.webVC.InitShowNavBlock = ^(BOOL show) { + @kStrongify(self); + self.toolView.hidden = YES; + }; + + self.webVC.CloseWebViewBlock = ^(BOOL result) { + [TTPopup dismiss]; + }; } - (void)initSubViewConstraints { @@ -61,15 +78,16 @@ make.bottom.mas_equalTo(self.toolView.mas_top); }]; + [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.bottom.mas_equalTo(self); + make.height.mas_equalTo(470); + }]; + CGFloat height = 430; [self.webVC.view mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self); - make.bottom.mas_equalTo(0); make.height.mas_equalTo(height); }]; [self.toolView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(0); - make.bottom.mas_equalTo(self.webVC.view.mas_top); make.height.mas_equalTo(44); }]; @@ -101,6 +119,17 @@ } } +- (UIStackView *)stackView { + if (!_stackView) { + _stackView = [[UIStackView alloc] init]; + _stackView.axis = UILayoutConstraintAxisVertical; + _stackView.distribution = UIStackViewDistributionFill; + _stackView.alignment = UIStackViewAlignmentFill; + _stackView.spacing = 0; + } + return _stackView; +} + - (UIView *)topView { if (!_topView) { _topView = [[UIView alloc] init]; diff --git a/xplan-ios/Main/XPWebViewController.h b/xplan-ios/Main/XPWebViewController.h index 3335da4b..0503a082 100644 --- a/xplan-ios/Main/XPWebViewController.h +++ b/xplan-ios/Main/XPWebViewController.h @@ -19,7 +19,10 @@ NS_ASSUME_NONNULL_BEGIN /// URL加载完成回调,result:加载结果成功/失败,error:失败原因 @property (nonatomic, copy) void (^urlLoadCompleted)(BOOL result, NSError * _Nullable error); - +///是都隐藏导航栏 目前适用于半屏的情况下 +@property (nonatomic,copy) void (^InitShowNavBlock)(BOOL show); +///关闭webView 目前适用于半屏的情况下 +@property (nonatomic,copy) void (^CloseWebViewBlock)(BOOL result); @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/XPWebViewController.m b/xplan-ios/Main/XPWebViewController.m index 9048c8cc..5fe46e85 100644 --- a/xplan-ios/Main/XPWebViewController.m +++ b/xplan-ios/Main/XPWebViewController.m @@ -241,11 +241,19 @@ NSString * const kCloseWebView = @"closeWebView"; }]; } else if([message.name isEqualToString:kInitShowNav]) { if (((NSNumber *)message.body).intValue == 0) { + if (self.InitShowNavBlock) { + self.InitShowNavBlock(YES); + return; + } if (self.navigationController) { [self.navigationController setNavigationBarHidden:YES]; } } } else if([message.name isEqualToString:kCloseWebView]) { + if (self.CloseWebViewBlock) { + self.CloseWebViewBlock(YES); + return; + } if (self.navigationController) { [self.navigationController popViewControllerAnimated:YES]; }