Files
blockly/demos/mobile/ios/Blockly WebView/ViewController.swift
Andrew n marshall 41236749ae Moving all mobile demos into demos/mobile.
HTML for both demos is now checked in as demos/mobile/html/index.html.
Updated android and ios scripts to copy webview.html from above.
2018-09-17 17:23:28 -07:00

39 lines
1.0 KiB
Swift

//
// ViewController.swift
// Blockly WebView
//
// Created by Andrew Marshall on 8/7/18.
// Copyright © 2018 Google. All rights reserved.
//
import UIKit
import WebKit
class ViewController: UIViewController {
/// The name used to reference this iOS object when executing callbacks from the JS code.
/// If this value is changed, it should also be changed in the `CODE_GENERATOR_BRIDGE_JS` file.
fileprivate static let HOST_HTML = "Blockly/webview.html"
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
loadWebView()
}
func loadWebView() {
if let htmlUrl = Bundle.main.url(forResource: "webview", withExtension: "html", subdirectory: "Blockly") {
webView.load(URLRequest.init(url: htmlUrl))
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}