Browse Source

tabbar商城web隐藏返回按钮

Steven 11 months ago
parent
commit
f9de840a98

+ 44 - 0
KulexiuForStudent/KulexiuForStudent/Module/Mall/Controller/ShopMallViewController.m

@@ -6,9 +6,13 @@
 //
 
 #import "ShopMallViewController.h"
+// 错误刷新web 页面
+#import "KSWebLoadRefreshView.h"
 
 @interface ShopMallViewController ()
 
+@property (nonatomic, strong) KSWebLoadRefreshView *mallErrorView;
+
 @end
 
 @implementation ShopMallViewController
@@ -26,6 +30,46 @@
     // Do any additional setup after loading the view.
 }
 
+
+- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
+    
+    NSLog(@"6-------页面加载失败时调用");
+    [self showMallErrorView];
+}
+
+- (void)showMallErrorView {
+    if (![self.view.subviews containsObject:self.mallErrorView]) {
+        [self.view addSubview:self.mallErrorView];
+        [self.mallErrorView mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.left.right.top.bottom.mas_equalTo(self.view);
+        }];
+        [self.view bringSubviewToFront:self.mallErrorView];
+    }
+}
+
+- (void)hideMallErrorView {
+    if ([self.view.subviews containsObject:self.mallErrorView]) {
+        [self.mallErrorView removeFromSuperview];
+    }
+}
+
+- (KSWebLoadRefreshView *)mallErrorView {
+    if (!_mallErrorView) {
+        _mallErrorView = [KSWebLoadRefreshView shareInstance];
+        _mallErrorView.hideBackButton = YES;
+        MJWeakSelf;
+        [_mallErrorView failViewActionCallback:^(BOOL isBack) {
+            [weakSelf hideMallErrorView];
+            if (isBack) {
+                [weakSelf backAction];
+            }
+            else {
+                [weakSelf loadRequest];
+            }
+        }];
+    }
+    return _mallErrorView;
+}
 /*
 #pragma mark - Navigation