首页 > 解决方案 > 如何将用户输入的数据插入本地 html 文档

问题描述

我对 Swift 很陌生,我正在为一个简单的任务而苦苦挣扎。我制作了一个简单的应用程序,它将启动一个本地 HTML 文件。

我现在想添加一个出现的文本框,询问用户“输入 IP 地址”。然后,该文本将被插入到 HTML 文件的 3 个不同位置。

有人对此有任何想法吗?或者知道一个可能有一些与这个想法相关的教程的好网站?到目前为止,这是我的代码:

import UIKit
import WebKit

class ViewController: UIViewController {

    @IBOutlet weak var htmlload: WKWebView!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        let htmlpath = Bundle.main.path(forResource: "index", ofType: "html")
        let url = URL(fileURLWithPath: htmlpath!)
        let request = URLRequest(url: url)
        htmlload.load(request)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

标签: iosswiftwkwebview

解决方案


推荐阅读