Guest User

Untitled

a guest
Jan 22nd, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  2. {
  3. NSURL * newUrl = [request URL];
  4. NSString * scheme = [[newUrl scheme] lowercaseString];
  5. if ([scheme hasPrefix:@"http"] || [scheme hasPrefix:@"app"] || [scheme hasPrefix:@"file"] || [scheme hasPrefix:@"ftp"])
  6. {
  7. /* Start PDF Anzeige abfangen */
  8. NSString *urlExtension = newUrl.absoluteString;
  9. NSArray *urlChunks = [urlExtension componentsSeparatedByString: @"."];
  10. urlExtension = [urlChunks lastObject];
  11. if ([urlExtension isEqualToString:@"pdf"]) {
  12. if (webView.scalesPageToFit) {
  13. return YES;
  14. }
  15. if ([self.proxy _hasListeners:@"loadPdf"]) {
  16. NSDictionary *event = newUrl == nil ? nil : [NSDictionary dictionaryWithObject:[newUrl absoluteString] forKey:@"url"]; [self.proxy fireEvent:@"loadPdf" withObject:event];
  17. }
  18. return NO;
  19. }
  20.  
  21. return YES;
  22. }
  23.  
  24. UIApplication * uiApp = [UIApplication sharedApplication];
  25.  
  26. if ([uiApp canOpenURL:newUrl])
  27. {
  28. [uiApp openURL:newUrl];
  29. return NO;
  30. }
  31.  
  32. //It's likely to fail, but that way we pass it on to error handling.
  33. return YES;
  34. }
Add Comment
Please, Sign In to add comment