Repository navigation
Expand file tree
/
Copy pathDZNWebViewController.h
More file actions
184 lines (141 loc) · 7.03 KB
/
Copy pathDZNWebViewController.h
File metadata and controls
184 lines (141 loc) · 7.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//
// DZNWebViewController.h
// DZNWebViewController
// https://github.com/dzenbot/DZNWebViewController
//
// Created by Ignacio Romero Zurbuchen on 10/25/13.
// Copyright (c) 2014 DZN Labs. All rights reserved.
// Licence: MIT-Licence
//
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
/**
Types of supported navigation tools.
*/
typedef NS_OPTIONS(NSUInteger, DZNWebNavigationTools) {
DZNWebNavigationToolAll = -1,
DZNWebNavigationToolNone = 0,
DZNWebNavigationToolBackward = (1 << 0),
DZNWebNavigationToolForward = (1 << 1),
DZNWebNavigationToolStopReload = (1 << 2),
};
/**
Types of supported actions (i.e. Share & Copy link, Add to Reading List, Open in Safari/Chrome/Opera/Dolphin).
*/
typedef NS_OPTIONS(NSUInteger, DZNsupportedWebActions) {
DZNWebActionAll = -1,
DZNWebActionNone = 0,
DZNsupportedWebActionshareLink = (1 << 0),
DZNWebActionCopyLink = (1 << 1),
DZNWebActionReadLater = (1 << 2),
DZNWebActionOpenSafari = (1 << 3),
};
/**
Types of information to be shown on navigation bar. Default is DZNWebNavigationPromptAll.
*/
typedef NS_OPTIONS(NSUInteger, DZNWebNavigationPrompt) {
DZNWebNavigationPromptNone = 0,
DZNWebNavigationPromptTitle = (1 << 0),
DZNWebNavigationPromptURL = (1 << 1),
DZNWebNavigationPromptAll = DZNWebNavigationPromptTitle | DZNWebNavigationPromptURL,
};
@protocol DZNNavigationDelegate;
@interface DZNWebView : WKWebView
@property (nonatomic, weak) id <DZNNavigationDelegate> navDelegate;
@end
@protocol DZNNavigationDelegate <WKNavigationDelegate>
- (void)webView:(DZNWebView *)webView didUpdateProgress:(CGFloat)progress;
@end
/**
A very simple web browser with useful navigation and tooling features.
*/
@interface DZNWebViewController : UIViewController <DZNNavigationDelegate, WKUIDelegate, UITableViewDataSource, UITableViewDelegate>
/* lzy注170805:
把TO的『done』按钮的移植过来
*/
/**
Shows the Done button when presented modally. When tapped, it dismisses the view controller.
Default value is YES.
*/
@property (nonatomic,assign) BOOL showDoneButton;
/**
If desired, override the title of the system 'Done' button to this string.
Default value is nil.
*/
@property (nonatomic,copy) NSString *doneButtonTitle;
/** The web view that the controller manages. */
@property (nonatomic, strong) DZNWebView *webView;
/** The URL identifying the location of the content to load. */
@property (nonatomic, readwrite) NSURL *URL;
/** The supported navigation tool bar items. Default is All. */
@property (nonatomic, readwrite) DZNWebNavigationTools supportedWebNavigationTools;
/** The supported actions like sharing and copy link, add to reading list, open in Safari, etc. Default is All. */
@property (nonatomic, readwrite) DZNsupportedWebActions supportedWebActions;
/** The information to be shown on navigation bar. Default is DZNWebNavigationPromptAll. */
@property (nonatomic, readwrite) DZNWebNavigationPrompt webNavigationPrompt;
/** Yes if a progress bar indicates the . Default is YES. */
@property (nonatomic) BOOL showLoadingProgress;
/** YES if long pressing the backward and forward buttons the navigation history is displayed. Default is YES. */
@property (nonatomic) BOOL allowHistory;
/** YES if both, the navigation and tool bars should hide when panning vertically. Default is YES. */
@property (nonatomic) BOOL hideBarsWithGestures;
/** [Deprecated] YES if should set the title automatically based on the page title and URL. Default is YES. */
@property (nonatomic) BOOL showPageTitleAndURL __deprecated_msg("Use 'webNavigationPrompt' instead.");
///------------------------------------------------
/// @name Initialization
///------------------------------------------------
/**
Initializes and returns a newly created webview controller with an initial HTTP URL to be requested as soon as the view appears.
@param URL The HTTP URL to be requested.
@returns The initialized webview controller.
*/
- (instancetype)initWithURL:(NSURL *)URL;
/**
Initializes and returns a newly created webview controller for local HTML navigation.
@param URL The file URL of the main html.
@returns The initialized webview controller.
*/
- (instancetype)initWithFileURL:(NSURL *)URL;
/**
Starts loading a new request. Useful to programatically update the web content.
@param URL The HTTP or file URL to be requested.
*/
- (void)loadURL:(NSURL *)URL NS_REQUIRES_SUPER;
/**
Starts loading a new request. Useful to programatically update the web content.
@param URL The HTTP or file URL to be requested.
@param baseURL A URL that is used to resolve relative URLs within the document.
*/
- (void)loadURL:(NSURL *)URL baseURL:(NSURL *)baseURL;
///------------------------------------------------
/// @name Appearance customisation
///------------------------------------------------
// The back button displayed on the tool bar (requieres DZNWebNavigationToolBackward)
@property (nonatomic, strong) UIImage *backwardButtonImage;
// The forward button displayed on the tool bar (requieres DZNWebNavigationToolForward)
@property (nonatomic, strong) UIImage *forwardButtonImage;
// The stop button displayed on the tool bar (requieres DZNWebNavigationToolStopReload)
@property (nonatomic, strong) UIImage *stopButtonImage;
// The reload button displayed on the tool bar (requieres DZNWebNavigationToolStopReload)
@property (nonatomic, strong) UIImage *reloadButtonImage;
// The action button displayed on the navigation bar (requieres at least 1 DZNsupportedWebActions value)
@property (nonatomic, strong) UIImage *actionButtonImage;
///------------------------------------------------
/// @name Delegate Methods Requiring Super
///------------------------------------------------
// DZNNavigationDelegate
- (void)webView:(DZNWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation NS_REQUIRES_SUPER;
- (void)webView:(DZNWebView *)webView didCommitNavigation:(WKNavigation *)navigation NS_REQUIRES_SUPER;
- (void)webView:(DZNWebView *)webView didUpdateProgress:(CGFloat)progress NS_REQUIRES_SUPER;
- (void)webView:(DZNWebView *)webView didFinishNavigation:(WKNavigation *)navigation NS_REQUIRES_SUPER;
- (void)webView:(DZNWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error NS_REQUIRES_SUPER;
// WKUIDelegate
- (DZNWebView *)webView:(DZNWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures NS_REQUIRES_SUPER;
// UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView NS_REQUIRES_SUPER;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section NS_REQUIRES_SUPER;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath NS_REQUIRES_SUPER;
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath NS_REQUIRES_SUPER;
// UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath NS_REQUIRES_SUPER;
@end