Swift将Html代码放入URL

Swift将Html代码放入URL,html,swift,webview,Html,Swift,Webview,我有如下Html表单: <form action="https:..." method="post"> <input name=".." value=".." type="hidden"/> <input name=".." value=".." type="hidden"/> <input name=".." value=".." type="hidden"> <input name=".." value="

我有如下Html表单:

<form action="https:..." method="post">
    <input name=".." value=".." type="hidden"/>
    <input name=".." value=".." type="hidden"/>
    <input name=".." value=".." type="hidden">
    <input name=".." value="nil" type="hidden"/>
    <input name=".." value=".." type="hidden"/>
    <input name=".." value=".." type="hidden"/>
    <input name=".." value=".." type="hidden">
    <input type=".." value="PPP" style="background: #3aaf42; border: none; color: #fff; text-align: center; width: 100px; padding: 5px; margin: -15px 0 0 -50px; display: block; top: 50%; border-radius: 3px; position: absolute; left: 50%;\"/>
</form>
但是不行,请帮帮我试试这个

1) 编辑与此相同的字符串

如果您使用swift 4或更高版本,您可以使用

不是这个,这些是用来请求url的

let myURL = URL(string: "<form...")
 let myRequest = URLRequest(url: myURL!)
 webView.load(myRequest)

let myURL=URL(string:“必须使用
webView.loadHTMLString(“@a.masri)”它没有帮助,因为它有许多“”和xCode显示错误我正在添加答案见她
        var myHtml  = """
<form action="https:..." method="post">
        <input name=".." value=".." type="hidden"/>
        <input name=".." value=".." type="hidden"/>
        <input name=".." value=".." type="hidden">
        <input name=".." value="nil" type="hidden"/>
        <input name=".." value=".." type="hidden"/>
        <input name=".." value=".." type="hidden"/>
        <input name=".." value=".." type="hidden">
        <input type=".." value="PPP" style="background: #3aaf42; border: none; color: #fff; text-align: center; width: 100px; padding: 5px; margin: -15px 0 0 -50px; display: block; top: 50%; border-radius: 3px; position: absolute; left: 50%;\"/>
        </form>
"""
    var myHtml  = "<form action=\"https:...\" method=\"post\">" +
     "<input name=\"..\" value=\"..\" type=\"hidden\"/>" +
    "<input name=\"..\" value=\"..\" type=\"hidden\"/>" +
    "<input name=\"..\" value=\"..\" type=\"hidden\">" +
    "<input name=\"..\" value=\"nil\" type=\"hidden\"/>" +
    "<input name=\"..\" value=\"..\" type=\"hidden\"/>" +
    "<input name=\"..\" value=\"..\" type=\"hidden\"/>" +
    "<input name=\"..\" value=\"..\" type=\"hidden\">" +
    "<input type=\"..\" value=\"PPP\" style=\"background: #3aaf42; border: none; color: #fff; text-align: center; width: 100px; padding: 5px; margin: -15px 0 0 -50px; display: block; top: 50%; border-radius: 3px; position: absolute; left: 50%;\\\"/>"
 webView.loadHTMLString(myHtml, baseURL: nil)
let myURL = URL(string: "<form...")
 let myRequest = URLRequest(url: myURL!)
 webView.load(myRequest)