网络视图首先将网址加载到登录页面。当用户第一次登录并选择复选框以记住用户名时,请将用户名保存为核心数据。当用户再次登录时,自动填充存储在核心数据中的用户名的用户名文本字段。自动填充网页视图的用户名
这会在Swift中完成吗?
网络视图首先将网址加载到登录页面。当用户第一次登录并选择复选框以记住用户名时,请将用户名保存为核心数据。当用户再次登录时,自动填充存储在核心数据中的用户名的用户名文本字段。自动填充网页视图的用户名
这会在Swift中完成吗?
当你的用户首创的迹象需要听
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool
在这里你可以得到数据后,它应该包含用户名,密码,并记住用户名值。检查记住用户名是否被选中,然后将用户名保存到核心数据。
当用户在任何其他时间登录时,请使用webViewDidFinishLoad(_ webView: UIWebView)
来填写用户名文本字段。
您可以通过使用webView.stringByEvaluatingJavaScript(from: String)
你需要使用一些javascript做到这一点,它应该是这样的。
document.getElementByID('id of the username text field').value = username
因此,对于您的网站,您的委托方法应该看起来像这样。
func webViewDidFinishLoad(_ webView: UIWebView) {
if let url = webView.request?.url {
if url.absoluteString == "https://retail.onlinesbi.com/retail/login.htm" {
// Autofill the username and password here.
webView.stringByEvaluatingJavaScript(from: "document.getElementById('username').value = \"username\"")
webView.stringByEvaluatingJavaScript(from: "document.getElementById('label2').value = \"password\"")
}
}
}
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if let url = webView.request?.url {
if url.absoluteString == "https://retail.onlinesbi.com/retail/login.htm" {
// Get the username and password here.
let username = webView.stringByEvaluatingJavaScript(from: "document.getElementById('username').value")
let password = webView.stringByEvaluatingJavaScript(from: "document.getElementById('label2').value")
}
}
return true
}
https://retail.onlinesbi.com/retail/login.htm这是我的网址如何尝试这个?? @Tristan Beaton –
我已经更新了与该网站一起使用的代码。 –
thnk你。 @Tristane Beaton>我会试试这个ñ通知你是否工作。 –
到目前为止你做了什么?这不是一个具体问题;它相当广泛。将其缩小到特定问题,而不是要求我们为您开发整个应用程序。 –