How to retrieve the html presented in a UIWebView with swift for IOS

0

When my application starts the viewDidLoad method, it runs a snippet of code that accesses an X site, retrieves an HTML form and displays it in a UIWebView.

My problem is this, when a link is clicked I need to intercept the return HTML to perform another treatment, however, I do not know how to detect that the webview was updated with a new request, or even get the html present.

    
asked by anonymous 19.10.2015 / 00:26

2 answers

0

HTML ...

<html>
<body>
<input id="myId" type="hidden" value="TextValue"/>
</body>
</html>

No Swift ...

var id:String = IBwebView.stringByEvaluatingJavaScriptFromString("document.getElementById('myId').value")!
println(id)

in the Obj c:

NSString* value = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('myId').value"];
    
19.10.2015 / 23:38
0

You must implement the UIWebViewDelegate protocol, and perform the action you need in the viewDidFinishLoad method.

    
20.10.2015 / 11:20