Skip to content

Super-light Interface Builder-compatibile WKWebView subclass

License

Notifications You must be signed in to change notification settings

giulio92/GLExtendedWebView

Repository files navigation

GLExtendedWebView

Branch Status
master BuddyBuild
develop BuddyBuild

Language Supported platforms codebeat badge license

What it is

GLExtendedWebView is a drop-in, ready to use, WKWebView subclass that brings Interface Builder compatibility to WKWebView, something that Apple seems to have forgot.

Why I created it

If you try to create a WKWebView using Interface Builder and you look for it in the object library the only thing you would find is UIWebView which Apple itself does not recommend:

From Apple's WKWebView documentation:

Important

Starting in iOS 8.0 and OS X 10.10, use WKWebView to add web content to your app. Do not use UIWebView or WebView.

another thing you would try at this point is to create a UIView and change its class to WKWebView but also won't work because the required method:

init?(coder: NSCoder)

has not been implemented in WKWebView. So in the end you will probably end up creating it programmatically in your UIViewController, but, unless you also apply some NSLayoutConstraints manually, it won't fit the screen on every device and/or update automatically upon rotation.

How to use / Installation

  1. Download the project
  2. Add the GLExtendedWebView class to your project
  3. Add a UIView in your UIViewController
  4. Change the UIView class to GLExtendedWebView
  5. Apply the required NSLayoutConstraint using the Interface Builder

Requirements

  • Xcode 9.0+
  • Swift 4.0+
  • iOS 9.0+

About

Super-light Interface Builder-compatibile WKWebView subclass

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages