Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Did you tried <code>setMarkedText:selectedRange:</code>?</p> <p><a href="http://developer.apple.com/library/iOS/#documentation/UIKit/Reference/UITextInput_Protocol/Reference/Reference.html" rel="nofollow">Apple developer lib</a></p> <p><strong>Update:</strong></p> <p>While you can't use <code>setMarkedText</code> inside the <code>UIWebView</code> there is no way but using JavaScript. I don't know, if you can manipulate the HTML page that you are showing or not? you can add this script in the page. If you can't manipulate the page you should load an <code>iframe</code> inside your <code>UIWebView</code> that loads your actual page and after the <code>iframe</code> add this script.</p> <p>Here is the script:</p> <pre><code>document.addEventListener('mouseup', function(){ if(getSelection().anchorNode != null ){ var sel = getSelection(), range = sel.getRangeAt(0), nodeValue = sel.anchorNode.nodeValue, lastCharIndex = range.endOffset, firstCharIndex = range.startOffset, lastChar = nodeValue.substr(lastCharIndex, 1), firstChar = nodeValue.substr(firstCharIndex, 1); while(lastChar != (" " || ".")){ lastChar = nodeValue.substr(lastCharIndex, 1); lastCharIndex++; }; while(firstChar != " "){ firstChar = nodeValue.substr(firstCharIndex, 1); firstCharIndex--; }; range.setEnd(sel.anchorNode, lastCharIndex-1); sel.addRange(range); range.setStart(sel.anchorNode, firstCharIndex+2); sel.addRange(range); } }, false); </code></pre> <p>I tested this on my iPhone and it was working fine.</p> <p>Here is the <a href="http://jsfiddle.net/9jsrd/embedded/result/" rel="nofollow">Demo</a> (just select something). I spent a lot time on it. I hope you enjoy it.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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