Am developing an app which load a HTML page into uiwebview - that html file contains text-filed and drop-down list, text-boxes etc..
Here How to get values which user has entered in that text-filed and answers selected from drop-down(picker).
Thanks
A view that embeds web content in your app.
Overview. A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app's UI. A web view supports a full web-browsing experience, and presents HTML, CSS, and JavaScript content alongside your app's native views.
To clear old contents of webview With UIWebView you would use UIWebViewDelegate 's - webViewDidFinishLoad: .
Here's how: Open the XIB or Storyboard you want to add the web view to in Interface Builder. Find the web view or WKWebView in the Object Library at the bottom-left of Interface Builder. Drag-and-drop a WKWebView object from the Object Library to your view controller's canvas, and adjust its size and position.
You can use [UIWebView stringByEvaluatingJavascriptFromString:]
method and get the values by executing the javascript.
Example: If your html is:
<html> <body> <input id="myId" type="text" value="TextValue"/> </body> </html>
Following code can get you the value of the text field:
NSString* value = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('myId').value"];
You can either poll a javascript function inside the page (using UIWebView stringByEvaluatingJavascriptFromString:).
Or you could call an objective-c method directly from the page using a little hack: UIWEBVIEW SECRETS - PART3 - HOW TO PROPERLY CALL OBJECTIVEC FROM JAVASCRIPT
(scroll down to the bottom for github-link).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With