This repository was archived by the owner on Feb 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathFLUIWebView.swift
More file actions
48 lines (37 loc) · 1.42 KB
/
FLUIWebView.swift
File metadata and controls
48 lines (37 loc) · 1.42 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
import UIKit
extension UIWebView: FLWebViewProvider {
// A simple convenience initializer, this allows for UIWebView(delegateView:) initialization
convenience init(delegateView: UIWebViewDelegate) {
self.init()
self.delegate = delegateView
}
// UIWebView has one delegate method so this is pretty straight forward
func setDelegateViews(viewController: ViewController) {
delegate = viewController
}
func canNavigateBack() -> Bool {
return self.canGoBack
}
func canNavigateForward() -> Bool {
return self.canGoForward
}
// A quick method for loading requests based on strings in a URL format
func loadRequestFromString(urlNameAsString: String!) {
loadRequest(NSURLRequest(URL: NSURL(string: urlNameAsString)!))
}
func currentURL() -> NSURL? {
return self.request?.URL
}
func evaluateJavaScriptString(javascriptString: String!, completionHandler: (AnyObject?, NSError?) -> ()) {
// Have the WebView evaluate the javascript string
guard let string = stringByEvaluatingJavaScriptFromString(javascriptString) else {
completionHandler(nil, nil)
return
}
// Call the completion handler from there
completionHandler(string, nil)
}
func setScalesPageToFit(setPages: Bool!) {
self.scalesPageToFit = setPages
}
}