How to recover the html displayed in a Uiwebview with Swift for IOS

Asked

Viewed 74 times

0

When my application starts the method viewDidLoad executes a code snippet 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 nor how to pick up the html there.

2 answers

0

in HTML...

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

in Swift...

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

in Obj c:

NSString* value = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('myId').value"];
  • I need to capture all the return html, I mean, I want to capture all the return code.

0

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.