SPWebViewController.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // SPWebViewController.m
  3. // SDLPal
  4. //
  5. // Created by palxex on 2017/6/13.
  6. // Copyright © 2017年 SDLPAL team. All rights reserved.
  7. //
  8. #import "SPWebViewController.h"
  9. #define UIKitLocalizedString(key) [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] localizedStringForKey:key value:@"" table:nil]
  10. @interface SPWebViewController ()<UIWebViewDelegate> {
  11. BOOL finished;
  12. }
  13. @property (strong, nonatomic) IBOutlet UIWebView *webView;
  14. @end
  15. @implementation SPWebViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view.
  19. [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
  20. [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
  21. }
  22. - (void)didReceiveMemoryWarning {
  23. [super didReceiveMemoryWarning];
  24. // Dispose of any resources that can be recreated.
  25. }
  26. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
  27. if( [request.URL.path hasSuffix:self.signature] ) {
  28. [self.navigationController popViewControllerAnimated:YES];
  29. [self.delegate capturedURL:request.URL];
  30. return NO;
  31. }
  32. return !finished;
  33. }
  34. - (void)webViewDidFinishLoad:(UIWebView *)webView {
  35. finished = YES;
  36. [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
  37. [self setTitle:[self.webView stringByEvaluatingJavaScriptFromString:@"document.title"]];
  38. }
  39. /*
  40. #pragma mark - Navigation
  41. // In a storyboard-based application, you will often want to do a little preparation before navigation
  42. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  43. // Get the new view controller using [segue destinationViewController].
  44. // Pass the selected object to the new view controller.
  45. }
  46. */
  47. @end