|
@@ -43,26 +43,6 @@ static NSURLCredential* clientAuthenticationCredential;
|
43
|
43
|
BOOL _savedHideKeyboardAccessoryView;
|
44
|
44
|
}
|
45
|
45
|
|
46
|
|
-- (void)dealloc{}
|
47
|
|
-
|
48
|
|
-/**
|
49
|
|
- * See https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/WebKitAvail.html.
|
50
|
|
- */
|
51
|
|
-+ (BOOL)dynamicallyLoadWebKitIfAvailable
|
52
|
|
-{
|
53
|
|
- static BOOL _webkitAvailable=NO;
|
54
|
|
- static dispatch_once_t onceToken;
|
55
|
|
-
|
56
|
|
- dispatch_once(&onceToken, ^{
|
57
|
|
- NSBundle *webKitBundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/WebKit.framework"];
|
58
|
|
- if (webKitBundle) {
|
59
|
|
- _webkitAvailable = [webKitBundle load];
|
60
|
|
- }
|
61
|
|
- });
|
62
|
|
-
|
63
|
|
- return _webkitAvailable;
|
64
|
|
-}
|
65
|
|
-
|
66
|
46
|
- (instancetype)initWithFrame:(CGRect)frame
|
67
|
47
|
{
|
68
|
48
|
if ((self = [super initWithFrame:frame])) {
|
|
@@ -91,6 +71,11 @@ static NSURLCredential* clientAuthenticationCredential;
|
91
|
71
|
return self;
|
92
|
72
|
}
|
93
|
73
|
|
|
74
|
+- (void)dealloc
|
|
75
|
+{
|
|
76
|
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
77
|
+}
|
|
78
|
+
|
94
|
79
|
/**
|
95
|
80
|
* See https://stackoverflow.com/questions/25713069/why-is-wkwebview-not-opening-links-with-target-blank/25853806#25853806 for details.
|
96
|
81
|
*/
|
|
@@ -105,10 +90,6 @@ static NSURLCredential* clientAuthenticationCredential;
|
105
|
90
|
- (void)didMoveToWindow
|
106
|
91
|
{
|
107
|
92
|
if (self.window != nil && _webView == nil) {
|
108
|
|
- if (![[self class] dynamicallyLoadWebKitIfAvailable]) {
|
109
|
|
- return;
|
110
|
|
- };
|
111
|
|
-
|
112
|
93
|
WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
|
113
|
94
|
if (_incognito) {
|
114
|
95
|
wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
|
|
@@ -186,6 +167,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
186
|
167
|
[_webView.configuration.userContentController removeScriptMessageHandlerForName:MessageHandlerName];
|
187
|
168
|
[_webView removeObserver:self forKeyPath:@"estimatedProgress"];
|
188
|
169
|
[_webView removeFromSuperview];
|
|
170
|
+ _webView.scrollView.delegate = nil;
|
189
|
171
|
_webView = nil;
|
190
|
172
|
}
|
191
|
173
|
|