IOS 12 UIWebView disappar

if you follow book, you will see the error

@IBOutlet weak var webview:UIWebView!

// if let url = Bundle.main.url(forResource: “BullsEye”,
// withExtension: “html”) {
// if let htmlData = try? Data(contentsOf: url) {
// let baseURL = URL(fileURLWithPath: Bundle.main.bundlePath)
// webview.load(htmlData, mimeType: “text/html”,
// textEncodingName: “UTF-8”,
// baseURL: baseURL)
// }
// }

Hi @maomao,
I am sorry that you are getting an error, would you be able to detail what error are you getting?

Here’s something that could help you in the meanwhile, iOS12 has deprecated the UIWebView so it could provide an issue. Since iOS12 is not released as yet and the details on the book page explicitly state that the current version of the book (v6.0) works with iOS11 and Swift 4 and Xcode 9.0.



UIWebView is deprecated even in iOS 11. You can use the new WKWebView instead on the storyboard. The only code changes needed are:

import WebKit


@IBOutlet weak var webView: WKWebView!

On my request, the university purchased the iOS apprentice book this July 2018.
I found that the book still did not update or work on the deprecations. As the author in the book mentioned they are updating in the october 2017 web-view-deprecated

Here is my solution to the issue

// AboutViewController.swift
// BullsEye
// Created by Akarsh Seggemu on 01.08.18.
// Copyright © 2018 Akarsh Seggemu. All rights reserved.

import UIKit
import WebKit

class AboutViewController: UIViewController {
@IBAction func close() {
dismiss(animated: true, completion: nil)

@IBOutlet weak var webView: WKWebView!

override func viewDidLoad() {
    let url = Bundle.main.path(forResource: "BullsEye", ofType: "html")
    let htmlUrl = URL(fileURLWithPath: url!, isDirectory: false)
    webView.loadFileURL(htmlUrl, allowingReadAccessTo: htmlUrl)


Two points:

  1. Deprecated does not mean that you can’t use the component - just that you should move on to something else since it would eventually be removed :slight_smile:

  2. The book has not been updated since the release of iOS 11. We are updating it for iOS 12 now but since iOS 12 is not out yet, the update will not be out till iOS 12 is released. This update does include changes to use WKWebView instead of UIWebView - the changes themselves are fairly simple and have already been documented several times in the forum, I believe.

This topic was automatically closed after 166 days. New replies are no longer allowed.