Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>see that post <a href="http://blog.techno-barje.fr/post/2010/10/06/UIWebView-secrets-part3-How-to-properly-call-ObjectiveC-from-Javascript/" rel="nofollow noreferrer">http://blog.techno-barje.fr/post/2010/10/06/UIWebView-secrets-part3-How-to-properly-call-ObjectiveC-from-Javascript/</a></p> <p>and that <a href="https://stackoverflow.com/questions/1662473/how-to-call-objective-c-from-javascript">How to call Objective-C from Javascript?</a></p> <p>you can send some string to your UIWebView using script</p> <pre><code>function sendURLToUIWebView(url) { var iframe = document.createElement("IFRAME"); iframe.setAttribute("src", url); document.documentElement.appendChild(iframe); iframe.parentNode.removeChild(iframe); } </code></pre> <p>your url should has specific schem f.e. <code>myappcomand://</code></p> <p>and you can handle it with <code>UIWebViewDelegate</code> method (set some object as delegate of UIWebView, f.e. some UIViewController)</p> <pre><code>- (BOOL)webView:(UIWebView *)aWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { BOOL shouldLoad = YES; if ([request.URL.scheme isEqualToString:@"myappcomand"]) { shouldLoad = NO; // parse url string "request.URL" and extract your parameters to store them } return shouldLoad; } </code></pre> <p>your javascript functions</p> <pre><code>function sendURLToUIWebView(url) { var iframe = document.createElement("IFRAME"); iframe.setAttribute("src", url); document.documentElement.appendChild(iframe); iframe.parentNode.removeChild(iframe); } function getRangeForSelectedText() { var selection = window.getSelection(); var range = selection.getRangeAt(0); var url = "myappcomand://" + "range=" + range; // you should convert range to string sendURLToUIWebView(url); } </code></pre> <p><strong>Update:</strong></p> <p>range to string</p> <pre><code>range.toString().replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '') </code></pre> <p>or just <code>var rangeText = window.getSelection().toString();</code></p> <p>see <a href="https://stackoverflow.com/questions/1586231/strange-behaviour-with-range-tostring">Strange behaviour with range.toString()</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload