Commit f8dbec924084f016bc745e5f0a13ef078b887cc8

Authored by 梁星国
1 parent 69ffe16f

提交网页返回更改

CNLiveServiceCenterModule/Assets/CNLiveServiceCenterModule.bundle/service_back@2x.png 0 → 100644

768 Bytes

CNLiveServiceCenterModule/Assets/CNLiveServiceCenterModule.bundle/service_back@3x.png 0 → 100644

1.3 KB

CNLiveServiceCenterModule/Classes/CNLiveServiceCenterModule/Controller/CNLiveBCreatorViewController.m
... ... @@ -17,6 +17,7 @@
17 17 #import <YYKit/YYKit.h>
18 18 #import <objc/runtime.h>
19 19 #import <CNLiveBaseKit/CNLiveBaseKit.h>
  20 +#import "UIImage+Service.h"
20 21  
21 22  
22 23 @interface CNLiveBCreatorViewController ()<WKNavigationDelegate,WKUIDelegate,UIScrollViewDelegate>
... ... @@ -36,6 +37,18 @@
36 37 [self.view setBackgroundColor:[UIColor whiteColor]];
37 38 [self initWKWebView];
38 39  
  40 + UIButton *btn = [[UIButton alloc]init];
  41 + btn.frame =CGRectMake(0, 0, 57, 44);
  42 + [btn setImage:[UIImage imageNamedFromService:@"service_back"] forState:(UIControlStateNormal)];//不起作用
  43 + [btn setTitle:@"返回" forState:UIControlStateNormal];
  44 + [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  45 + btn.titleLabel.font = [UIFont systemFontOfSize:14];
  46 + btn.contentEdgeInsets = UIEdgeInsetsMake(0, -8, 0, 8);
  47 + [btn addTarget:self action:@selector(backAction:) forControlEvents:(UIControlEventTouchUpInside)];//不起作用
  48 + UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
  49 +
  50 + self.navigationItem.leftBarButtonItem = leftItem;
  51 +
39 52  
40 53 }
41 54  
... ... @@ -63,6 +76,8 @@
63 76 }
64 77 [self.view insertSubview:webView belowSubview:progress];
65 78  
  79 + self.wkwebView = webView;
  80 +
66 81 }
67 82  
68 83 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
... ... @@ -86,6 +101,21 @@
86 101  
87 102 }
88 103  
  104 +- (void)backAction:(UIBarButtonItem *)item {
  105 +
  106 + NSLog(@"输出内容");
  107 + if ([self.wkwebView canGoBack]) {
  108 +
  109 + [self.wkwebView goBack];
  110 +
  111 + }else{
  112 +
  113 + [self.navigationController popViewControllerAnimated:YES];
  114 +
  115 + }
  116 +
  117 +}
  118 +
89 119  
90 120  
91 121  
... ...