项目作者: giulio92

项目描述 :
Super-light Interface Builder-compatibile WKWebView subclass
高级语言: Swift
项目地址: git://github.com/giulio92/GLExtendedWebView.git
创建时间: 2017-08-08T15:03:51Z
项目社区:https://github.com/giulio92/GLExtendedWebView

开源协议:MIT License

下载


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:

  1. 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+