ZCBaseWebView.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // ZCBaseBaseWebView.h
  3. // HuaKaiChat
  4. //
  5. // Created by 张灿 on 2017/6/28.
  6. // Copyright © 2017年 huakai. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @class ZCBaseWebView;
  10. @protocol ZCBaseWebViewDelegate <NSObject>
  11. @optional
  12. - (void)webViewDidStartLoad:(ZCBaseWebView * _Nonnull)webView;
  13. - (void)webViewDidFinishLoad:(ZCBaseWebView * _Nonnull)webView;
  14. - (void)webView:(ZCBaseWebView * _Nonnull)webView didFailLoadWithError:(nullable NSError *)error;
  15. - (void)webView:(ZCBaseWebView * _Nonnull)webView updateProgress:(double)progress;
  16. @end
  17. @interface ZCBaseWebView : UIView
  18. /* nav */
  19. @property (strong, nonatomic) UINavigationController *nav;
  20. @property(weak,nonatomic)_Nullable id<ZCBaseWebViewDelegate> delegate;
  21. @property (nonatomic,copy) NSString* contentUrl;
  22. ///内部使用的webView 如果有WKWebView则realWebView为WKWebView
  23. @property (nonatomic, readwrite) WKWebView *realWebView;
  24. //加载进度
  25. @property (nonatomic, readonly) double estimatedProgress;
  26. @property (nonatomic, copy) NSString * _Nullable title;
  27. ///---- UI 或者 WK 的API
  28. @property (nonatomic, readonly) UIScrollView* _Nullable scrollView;
  29. - (void)loadRequest:(NSURLRequest * _Nullable)request;
  30. - (void)loadHTMLString:(NSString * _Nullable)string baseURL:(nullable NSURL *)baseURL;
  31. - (nullable NSString *)stringByEvaluatingJavaScriptFromString:(NSString * _Nullable)script;
  32. @property (nullable, nonatomic, readonly, strong) NSURLRequest *request;
  33. @property (nonatomic, readonly, getter=canGoBack) BOOL canGoBack;
  34. @property (nonatomic, readonly, getter=canGoForward) BOOL canGoForward;
  35. @property (nonatomic, readonly, getter=isLoading) BOOL loading;
  36. @property (nonatomic) BOOL scalesPageToFit;
  37. @end
  38. //TLSWebProgressView
  39. extern const float NJKInitialProgressValue;
  40. extern const float NJKInteractiveProgressValue;
  41. extern const float NJKFinalProgressValue;
  42. typedef void (^ZCBaseWebProgressViewBlock)(float progress);
  43. @class ZCBaseWebProgressView;
  44. @protocol ZCBaseWebProgressViewDelegate <NSObject>
  45. - (void)webViewProgress:(ZCBaseWebProgressView *_Nullable)webViewProgress updateProgress:(float)progress;
  46. @end
  47. @interface ZCBaseWebProgressView : NSObject
  48. @property (nonatomic, weak) id<ZCBaseWebProgressViewDelegate >progressDelegate;
  49. @property (nonatomic, copy) ZCBaseWebProgressViewBlock progressBlock;
  50. @property (nonatomic, readonly) float progress; // 0.0..1.0
  51. - (void)reset;
  52. @end