Commit 52a972fee697cc057e306ade6cda1e734e99d312

Authored by zhangxiaowen
1 parent 424569aa

no message

Example/CNLiveBalanceModule/CNLIVEAppDelegate.m
@@ -70,8 +70,9 @@ @@ -70,8 +70,9 @@
70 // CNLiveBalanceController *vc = [[CNLiveBalanceController alloc] initWithType:@"1" ID:CNUserShareModel.uid]; 70 // CNLiveBalanceController *vc = [[CNLiveBalanceController alloc] initWithType:@"1" ID:CNUserShareModel.uid];
71 // CNLIVEViewController *vc = [[CNLIVEViewController alloc] initWithUrl:@"http://www.baidu.com" title:@"asdasd" closeHidden:NO]; 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 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc]; 76 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
76 self.window.rootViewController = nav;//设置根视图控制器 77 self.window.rootViewController = nav;//设置根视图控制器
77 [self.window makeKeyAndVisible]; 78 [self.window makeKeyAndVisible];
Example/CNLiveBalanceModule/CNLIVEViewController.h
@@ -10,4 +10,5 @@ @@ -10,4 +10,5 @@
10 10
11 @interface CNLIVEViewController : CNLiveInteractionWebController 11 @interface CNLIVEViewController : CNLiveInteractionWebController
12 12
  13 +
13 @end 14 @end
Example/CNLiveBalanceModule/CNLIVEViewController.m
@@ -15,11 +15,7 @@ @@ -15,11 +15,7 @@
15 @end 15 @end
16 16
17 @implementation CNLIVEViewController 17 @implementation CNLIVEViewController
18 -  
19 -- (void)createSubViews {  
20 - [super createSubViews];  
21 - [self interaction];  
22 -} 18 +#pragma mark - 交互
23 - (void)interaction { 19 - (void)interaction {
24 [super interaction]; 20 [super interaction];
25 [self.bridge registerHandler:@"wjjHelpAndFeedbackImage" handler:^(id data, WVJBResponseCallback responseCallback) { 21 [self.bridge registerHandler:@"wjjHelpAndFeedbackImage" handler:^(id data, WVJBResponseCallback responseCallback) {
@@ -35,6 +31,13 @@ @@ -35,6 +31,13 @@
35 NSLog(@"ObjC received response: %@", responseData); 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 #pragma mark - CNLiveWebViewDelegate 41 #pragma mark - CNLiveWebViewDelegate
39 - (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url { 42 - (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url {
40 NSLog(@"CNLIVEViewController - didFinishLoad"); 43 NSLog(@"CNLIVEViewController - didFinishLoad");
@@ -43,7 +46,7 @@ @@ -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,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
17 17
18 @interface CNLiveBaseWebViewController : CNLiveBaseViewController 18 @interface CNLiveBaseWebViewController : CNLiveBaseViewController
19 @property (nonatomic, strong) CNLiveWebView *webView; 19 @property (nonatomic, strong) CNLiveWebView *webView;
  20 +@property (nonatomic, copy) NSString *url;
20 21
21 - (instancetype)initWithUrl:(NSString *)url; 22 - (instancetype)initWithUrl:(NSString *)url;
22 - (instancetype)initWithUrl:(NSString *)url title:(nullable NSString *)title; 23 - (instancetype)initWithUrl:(NSString *)url title:(nullable NSString *)title;
Example/CNLiveBalanceModule/CNLiveBaseWebViewController.m
@@ -14,8 +14,6 @@ @@ -14,8 +14,6 @@
14 #import "CNLiveNavigationBar.h" 14 #import "CNLiveNavigationBar.h"
15 15
16 @interface CNLiveBaseWebViewController ()<CNLiveWebViewDelegate> 16 @interface CNLiveBaseWebViewController ()<CNLiveWebViewDelegate>
17 -@property (nonatomic, copy) NSString *url;  
18 -  
19 @property (nonatomic, strong) UIButton *closeBtn; 17 @property (nonatomic, strong) UIButton *closeBtn;
20 @property (nonatomic, assign) BOOL closeHidden; 18 @property (nonatomic, assign) BOOL closeHidden;
21 19
@@ -41,23 +39,28 @@ static const NSInteger margin = 10; @@ -41,23 +39,28 @@ static const NSInteger margin = 10;
41 return self; 39 return self;
42 } 40 }
43 41
44 -#pragma mark - 加载数据 42 +#pragma mark - Setter方法
45 - (void)setUrl:(NSString *)url{ 43 - (void)setUrl:(NSString *)url{
  44 + if(!url||[url isEqualToString:@""]) return;
46 _url = url; 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 - (NSString *)html:(NSString *)url{ 48 - (NSString *)html:(NSString *)url{
58 return [NSString stringWithFormat:@"<div style=\"font-size:45px\">%@</div>",url]; 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 - (void)createSubViews { 64 - (void)createSubViews {
62 [super createSubViews]; 65 [super createSubViews];
63 if(!self.closeHidden&&!self.navigationHidden){ 66 if(!self.closeHidden&&!self.navigationHidden){