-
Notifications
You must be signed in to change notification settings - Fork 1
BaseWebViewController
This class acts as a base view controller class for UIWebViewController and WKWebViewController. It defines the base values and functions used in subclesses of it. This class should not be used on it’s own, always use it as a subclass such as though UIWebViewController or WKWebViewController.
The web view. This will either be UIWebView or WKWebView depending on the requested type.
Declaration
Swift
var webView: AnyObject?
---
<br>
### activityIndicatorView
The activity indicator view showing if the web view is loading or not.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
let activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
The progress view to show the percent a web view has loaded. This will only be used in a WKWebView based controller.
Declaration
Swift
let progrssView = UIProgressView(progressViewStyle: .bar)
---
<br>
### backButton
The back button for the toolbar.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
var backButton: UIBarButtonItem?
The forward button for the toolbar.
Declaration
Swift
var forwardButton: UIBarButtonItem?
---
<br>
### urlString
The URL string to set for the page to be loaded.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public var urlString: String?
The URL of the current page.
Declaration
Swift
public var url: URL?
---
<br>
### titleOverride
The title to show in the navigation bar if something other than the loaded page’s title is required.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public var titleOverride: String?
Returns true if the web view is currently loading, false if not.
Declaration
Swift
public var loading: Bool
---
<br>
### stopLoading()
Stops the web view from being loaded any more.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public func stopLoading()
Declaration
Swift
public override func viewDidLoad()
---
<br>
### viewWillDisappear(_:)
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public override func viewWillDisappear(_ animated: Bool)
Declaration
Swift
public override func viewDidDisappear(_ animated: Bool)
---
<br>
### didReceiveMemoryWarning()
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public override func didReceiveMemoryWarning()
## Action Methods
Dismissed the current view if presented modally.
Declaration
Swift
func doneButtonPressed(_ sender: AnyObject?)
**Parameters**
<table>
<tr><td> `sender` </td><td> The bar button item pressed. </td></tr>
<table>
---
<br>
### refreshButtonPressed(_:)
Refrshes the web view when the refresh button is pressed in the toolbar.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
func refreshButtonPressed(_ sender: AnyObject?)
Parameters
| `sender` | The bar button item pressed. |
Requests the web view go back a page.
Declaration
Swift
func backButtonPressed(_ sender: AnyObject?)
**Parameters**
<table>
<tr><td> `sender` </td><td> The bar button item pressed. </td></tr>
<table>
---
<br>
### forwardButtonPressed(_:)
Requests the web view go forward a page.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
func forwardButtonPressed(_ sender: AnyObject?)
Parameters
| `sender` | The bar button item pressed. |
Calls and presents a UIActivityViewController.
Declaration
Swift
func actionButtonPressed(_ sender: AnyObject?)
**Parameters**
<table>
<tr><td> `sender` </td><td> The bar button item pressed. </td></tr>
<table>
---
<br>
## UI Update Methods <br>
### setupToolbar()
Sets up the toolbar with the required buttons and actions for them.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
func setupToolbar()
Updates the progress view with the current loading % of the web view if available, otherwise it hides the progress view.
Declaration
Swift
func updateProgrssViewVisability()
---
<br>
### updateActivityViewVisability()
Updates the activity indicator view of the web view if available, otherwise it hides the activity indicator view.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
func updateActivityViewVisability()
Updates the back button in the toolbar depending on if it should be active or not.
Declaration
Swift
func updateBackButton()
---
<br>
### updateForwardButton()
Updates the forward button in the toolbar depending on if it should be active or not.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
func updateForwardButton()
Updates the back and forwards button in the toolbar depending on if they should be active or not.
Declaration
Swift
func updateBackForwardButtons()
---
<br>
## Load Methods <br>
### loadBaseURL()
Creates a URL string, appending http:// if the URL string does not already have it as a prefix.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
func loadBaseURL() -> String
Return Value
The base URL string.