Skip to content

Web view controller

Gokhan Gultekin edited this page Oct 17, 2018 · 1 revision

Web view controller generally used for showing user agreements, privacy policies or websites.

Follow the steps below to call web view controller from your view controller.

Usage

Initialize the web view controller:

⚠️ Do not set nib name for it.

let webviewVC = V_WebViewController()

Load a URL to show on web view controller:

webviewVC.url = URL(string: "https://google.com")

Finally, you can present the image preview controller like a normal view controller:

present(webviewVC, animated: true, completion: nil)

If you want to include navigation bar in your web view controller, you can simply create your navigation controller and present it after setting its root view controller (it's optional):

let navigationController = UINavigationController(rootViewController: webviewVC)
present(navigationController, animated: true, completion: nil)

Notes

You can also change the appearance of your web view controller by editing attributes some of its UI elements such as:

  • navigationBar: UINavigationBar!
  • closeButton: UIBarButtonItem
  • title: String (navigation bar title)
  • activityIndicatorView: UIActivityIndicatorView (you may want to change the color of activity indicator or you can change the style to make it larger.)
Clone this wiki locally