Commit 52a972fee697cc057e306ade6cda1e734e99d312

Authored by zhangxiaowen
1 parent 424569aa

no message

Example/CNLiveBalanceModule/CNLIVEAppDelegate.m
... ... @@ -70,8 +70,9 @@
70 70 // CNLiveBalanceController *vc = [[CNLiveBalanceController alloc] initWithType:@"1" ID:CNUserShareModel.uid];
71 71 // CNLIVEViewController *vc = [[CNLIVEViewController alloc] initWithUrl:@"http://www.baidu.com" title:@"asdasd" closeHidden:NO];
72 72  
73   - CNLIVEViewController *vc = [[CNLIVEViewController alloc] initWithUrl:@"http://wjjh5test.cnlive.com/cnComplaint.html" title:@"" closeHidden:NO];
74   -
  73 + CNLIVEViewController *vc = [[CNLIVEViewController alloc] initWithUrl:@"http://wjjh5test.cnlive.com/cnComplaint.html" title:@"" closeHidden:NO];
  74 +// CNLIVEViewController *vc = [[CNLIVEViewController alloc] initWithUrl:@"" title:@"" closeHidden:NO];
  75 +
75 76 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
76 77 self.window.rootViewController = nav;//设置根视图控制器
77 78 [self.window makeKeyAndVisible];
... ...
Example/CNLiveBalanceModule/CNLIVEViewController.h
... ... @@ -10,4 +10,5 @@
10 10  
11 11 @interface CNLIVEViewController : CNLiveInteractionWebController
12 12  
  13 +
13 14 @end
... ...
Example/CNLiveBalanceModule/CNLIVEViewController.m
... ... @@ -15,11 +15,7 @@
15 15 @end
16 16  
17 17 @implementation CNLIVEViewController
18   -
19   -- (void)createSubViews {
20   - [super createSubViews];
21   - [self interaction];
22   -}
  18 +#pragma mark - 交互
23 19 - (void)interaction {
24 20 [super interaction];
25 21 [self.bridge registerHandler:@"wjjHelpAndFeedbackImage" handler:^(id data, WVJBResponseCallback responseCallback) {
... ... @@ -35,6 +31,13 @@
35 31 NSLog(@"ObjC received response: %@", responseData);
36 32 }];
37 33 }
  34 +
  35 +#pragma mark - Setter方法
  36 +- (void)setUrl:(NSString *)url{
  37 + if(!url||[url isEqualToString:@""]) return;
  38 + [super setUrl:[NSString stringWithFormat:@"%@?asd",url]];
  39 +}
  40 +
38 41 #pragma mark - CNLiveWebViewDelegate
39 42 - (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url {
40 43 NSLog(@"CNLIVEViewController - didFinishLoad");
... ... @@ -43,7 +46,7 @@
43 46 }
44 47 }
45 48  
46   -- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error{
  49 +- (void)webView:(CNLiveWebView *)webView didFailLoadWithError:(NSError *)error {
47 50  
48 51 }
49 52  
... ...
Example/CNLiveBalanceModule/CNLiveBaseWebViewController.h
... ... @@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
17 17  
18 18 @interface CNLiveBaseWebViewController : CNLiveBaseViewController
19 19 @property (nonatomic, strong) CNLiveWebView *webView;
  20 +@property (nonatomic, copy) NSString *url;
20 21  
21 22 - (instancetype)initWithUrl:(NSString *)url;
22 23 - (instancetype)initWithUrl:(NSString *)url title:(nullable NSString *)title;
... ...
Example/CNLiveBalanceModule/CNLiveBaseWebViewController.m
... ... @@ -14,8 +14,6 @@
14 14 #import "CNLiveNavigationBar.h"
15 15  
16 16 @interface CNLiveBaseWebViewController ()<CNLiveWebViewDelegate>
17   -@property (nonatomic, copy) NSString *url;
18   -
19 17 @property (nonatomic, strong) UIButton *closeBtn;
20 18 @property (nonatomic, assign) BOOL closeHidden;
21 19  
... ... @@ -41,23 +39,28 @@ static const NSInteger margin = 10;
41 39 return self;
42 40 }
43 41  
44   -#pragma mark - 加载数据
  42 +#pragma mark - Setter方法
45 43 - (void)setUrl:(NSString *)url{
  44 + if(!url||[url isEqualToString:@""]) return;
46 45 _url = url;
47   - if ([url hasPrefix:@"http://"]||[url hasPrefix:@"https://"]) {
48   - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0];
49   - [self.webView loadRequest:request];
50   -
51   - } else {
52   - [self.webView loadHTMLString:[self html:url]];
53   - }
54   -
55 46 }
56 47  
57 48 - (NSString *)html:(NSString *)url{
58 49 return [NSString stringWithFormat:@"<div style=\"font-size:45px\">%@</div>",url];
59 50 }
60 51  
  52 +#pragma mark - 生命周期
  53 +- (void)viewDidLoad {
  54 + [super viewDidLoad];
  55 + if ([_url hasPrefix:@"http://"]||[_url hasPrefix:@"https://"]) {
  56 + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:_url] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0];
  57 + [self.webView loadRequest:request];
  58 +
  59 + } else {
  60 + [self.webView loadHTMLString:[self html:_url]];
  61 + }
  62 +}
  63 +
61 64 - (void)createSubViews {
62 65 [super createSubViews];
63 66 if(!self.closeHidden&&!self.navigationHidden){
... ...