LoginSignup
0
1

More than 3 years have passed since last update.

Swift:WKWebViewでローカルファイルを開く時のTips

Posted at
import Cocoa
import WebKit

class ViewController: NSViewController {

    var webView: WKWebView? {
        return self.view as? WKWebView
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        guard let url = Bundle.main.url(forResource: "LocalFile", withExtension: "html") else { return }
        self.webView?.loadFileURL(url, allowingReadAccessTo: url)
    }

}

こんな感じでBundle内のHTMLファイルをWebViewに表示するとき、SandBoxNetwork: Outgoing Connections (client)にチェックを入れないとコンテンツが読み込まれない。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1