| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- //
- // WebViewController.m
- // RedAnt ERP Mobile
- //
- // Created by Ray on 1/21/16.
- // Copyright © 2016 United Software Applications, Inc. All rights reserved.
- //
- #import "WebViewController.h"
- #import "RAUtils.h"
- #import "const.h"
- @interface WebViewController ()
- @end
- @implementation WebViewController
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [[self navigationController] setNavigationBarHidden:NO animated:NO];
-
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // self.edgesForExtendedLayout = UIRectEdgeNone;
- // Do any additional setup after loading the view.
- UIRefreshControl *ref = [[UIRefreshControl alloc]init];
- ref.tag = 200 ;
- ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"drag to refresh"];
- ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
- // ref.hidden = true;
- [ref addTarget:self action:@selector(changeCell) forControlEvents:UIControlEventValueChanged];
- [self.wkWebview.scrollView addSubview:ref];
- self.wkWebview.navigationDelegate = self;
-
-
- // self.wkWebview.dataDetectorTypes=UIDataDetectorTypeAll;
-
- // self.wkWebview datade
-
-
- if(!_defaultBarbutton)
- {
- UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector( onBackClick:)];
- //[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
- // closeButton.title = @"Close";
- // closeButton.tintColor = UIColorFromRGB(0x996633);
- self.navigationItem.leftBarButtonItem = closeButton;
-
- }
-
-
-
-
-
- [self loadcontent];
- if(self.mumcolor)
- self.mum.color = self.mumcolor;
- }
- - (void)onBackClick:(UIButton *)sender {
- /*
- if (self.backItemDismiss)
- [self.navigationController dismissViewControllerAnimated:YES completion:nil];
-
- [self.navigationController popViewControllerAnimated:FALSE];*/
-
- //如果以下关闭有问题则回滚上面注释代码
-
- if (self.presentingViewController) {
- [self dismissViewControllerAnimated:YES completion:nil];
- } else {
- [self.navigationController popViewControllerAnimated:YES];
- }
-
- }
- -(void)ReloadData
- {
-
- // Count ++ ;
- // [mytabelview reloadData];
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-
- [reF endRefreshing];
- [self loadcontent];
-
-
- }
- -(void) loadcontent
- {
- self.mum.hidden=false;
-
-
- NSURL *url =[NSURL URLWithString:self.url];
- DebugLog(@"%@",self.url);
- NSURLRequest *request =[NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:self.timeout];
-
- // if(self.timeout>0)
- // request.timeoutInterval = self.timeout;
- [self.wkWebview loadRequest:request];
-
-
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
-
-
-
- }
- -(void)changeCell
- {
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
- reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"refreshing"];
- if ([self respondsToSelector:@selector(ReloadData)])
- [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
- // DebugLog(@"refresh!!!!!!!!");
-
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark - WKNavigationDelegate
- - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
- {
- self.mum.hidden=true;
-
-
- }
- - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error
- {
- self.mum.hidden=true;
- }
- - (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error
- {
- self.mum.hidden=true;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|