Migrating from UIWebView / WebView to WKWebView
WKWebView has been the preferred API since iOS 8. But if your app still hasn’t made the switch, be advised that UIWebView and WebView are formally deprecated in iOS 12 and macOS Mojave, and you should update to WKWebView as soon as possible.
To help make that transition, here’s a comparison of the APIs of UIWebView and WKWebView:
UIWebViewWKWebView
var scrollView: UIScrollView { get } | var scrollView: UIScrollView { get } |
var configuration: WKWebViewConfiguration { get } | |
var delegate: UIWebViewDelegate? | var UIDelegate: WKUIDelegate? |
var navigationDelegate: WKNavigationDelegate? | |
var backForwardList: WKBackForwardList { get } |
Loading
UIWebViewWKWebView
func loadRequest(request: URLRequest) | func load(_ request: URLRequest) -> WKNavigation? |
func loadHTMLString(string: String, baseURL: URL?) | func loadHTMLString(_: String, baseURL: URL?) -> WKNavigation? |
func loadData(_ data: Data, mimeType: String, characterEncodingName: String, baseURL: URL) -> WKNavigation? | |
var estimatedProgress: Double { get } | |
var hasOnlySecureContent: Bool { get } | |
func reload() | func reload() -> WKNavigation? |
func reloadFromOrigin(Any?) -> WKNavigation? | |
func stopLoading() | func stopLoading() |
var request: URLRequest? { get } | |
var URL: URL? { get } | |
var title: String? { get } |
History
UIWebViewWKWebView
func goToBackForwardListItem(item: WKBackForwardListItem) -> WKNavigation? | |
func goBack() | func goBack() -> WKNavigation? |
func goForward() | func goForward() -> WKNavigation? |
var canGoBack: Bool { get } | var canGoBack: Bool { get } |
var canGoForward: Bool { get } | var canGoForward: Bool { get } |
var loading: Bool { get } | var loading: Bool { get } |
Javascript Evaluation
UIWebViewWKWebView
func stringByEvaluatingJavaScriptFromString(script: String) -> String | |
func evaluateJavaScript(_ javaScriptString: String, completionHandler: ((AnyObject?, NSError?) -> Void)?) |
Miscellaneous
UIWebViewWKWebView
var keyboardDisplayRequiresUserAction: Bool | |
var scalesPageToFit: Bool | |
var allowsBackForwardNavigationGestures: Bool |
Pagination
WKWebView currently lacks equivalent APIs for paginating content.
- var paginationMode: UIWebPaginationMode
- var paginationBreakingMode: UIWebPaginationBreakingMode
- var pageLength: CGFloat
- var gapBetweenPages: CGFloat
- var pageCount: Int { get }
'개발도구 > iOS - 아이폰 개발' 카테고리의 다른 글
[ios] webview 쿠키 항상 허용 - NSHTTPCookieAcceptPolicyAlways (1) | 2014.12.31 |
---|---|
How to: Xcode 5.1 – No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386) (1) | 2014.12.23 |
ASIHTTPRequest in ARC (0) | 2014.12.15 |
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386) (1) | 2014.12.11 |
[iOS] CocoaPods 설치과정 및 시행착오 (0) | 2014.12.04 |