BUWebViewDefine.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // BUWebViewDefine.h
  3. // BURexxar
  4. //
  5. // Created by muhuai on 2017/5/17.
  6. // Copyright © 2017年 muhuai. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. #import "BURexxarEngine.h"
  11. #import "BUJSInjector.h"
  12. typedef NS_ENUM(NSInteger, BUWebViewNavigationType) {
  13. BUWebViewNavigationTypeLinkClicked,
  14. BUWebViewNavigationTypeFormSubmitted,
  15. BUWebViewNavigationTypeBackForward,
  16. BUWebViewNavigationTypeReload,
  17. BUWebViewNavigationTypeFormResubmitted,
  18. BUWebViewNavigationTypeOther
  19. };
  20. @protocol BUWebView;
  21. @protocol BUWebViewDelegate <NSObject>
  22. @optional
  23. - (BOOL)webView:(UIView<BUWebView> *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(BUWebViewNavigationType)navigationType;
  24. - (void)webViewDidStartLoad:(UIView<BUWebView> *)webView;
  25. - (void)webViewDidFinishLoad:(UIView<BUWebView> *)webView;
  26. - (void)webView:(UIView<BUWebView> *)webView didFailLoadWithError:(NSError *)error;
  27. - (void)webViewWebContentProcessDidTerminate:(UIView<BUWebView> *)webView API_AVAILABLE(macosx(10.11), ios(9.0));
  28. //二方页面有 domReady回调
  29. - (void)webViewDomReady:(UIView<BUWebView> *)webView;
  30. @end
  31. /**
  32. BUWKWebView 都会实现此协议, 用来对平两个容器之间API的差异
  33. */
  34. @protocol BUWebView <BURexxarEngine>
  35. @property (nonatomic, strong ,readonly) UIScrollView *ttr_scrollView;
  36. /**
  37. JS脚本注入器 使用说明见:BUJSInjector.h
  38. */
  39. @property (nonatomic, strong, readonly) BUJSInjector *ttr_injector;
  40. #pragma mark - Loading Content
  41. - (void)ttr_loadRequest:(NSURLRequest *)request;
  42. - (void)ttr_loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL;
  43. /**
  44. WK下特有的方法
  45. @param URL 本地文件URL, 注意需要为file://
  46. @param readAccessURL WK下可以指定获取一个本地目录的权限
  47. */
  48. - (void)ttr_loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)readAccessURL;
  49. - (void)ttr_stopLoading;
  50. - (void)ttr_reload;
  51. #pragma mark - Moving Back and Forward
  52. - (BOOL)ttr_canGoBack;
  53. - (BOOL)ttr_canGoForward;
  54. - (void)ttr_goBack;
  55. - (void)ttr_goForward;
  56. #pragma mark - Multi Delegate
  57. /**
  58. BUWKWebView内部实现成多路代理, 按注册的顺序来依次询问.
  59. @param delegate webview代理
  60. */
  61. - (void)ttr_addDelegate:(id<BUWebViewDelegate>)delegate;
  62. /**
  63. 移除指定代理
  64. @param delegate 需要移除的代理
  65. */
  66. - (void)ttr_removeDelegate:(id<BUWebViewDelegate>)delegate;
  67. /**
  68. 移除所有代理
  69. */
  70. - (void)ttr_removeAllDelegate;
  71. @end