When we highlight a text in UIWebView usually the copy, paste, define.. etc appears. How can I intercept this so that when I choose copy I call some other method/do something else. Is this possible?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
You can simply override -copy:
Edit to answer your comment.
Define is a bit trickier, since it's private. However, you could implement your own method. Set up the UIMenuController with your desired items.
Then you implement those methods.
As for define, it's way more complicated.. First, you need to check if the UIReferenceLibraryController has a definition, by overriding -canPerformAction:withSender:
-selectedText is here a category on UIWebView:
Then you need to implement myDefine:
Edit to answer you comment again
-rectForSelectedText is another custom category on UIWebView.
What it does is calling a javascript that returns a string that you can convert using CGRectFromString(), it looks something like this:
Check this page to learn how to inject javascript into UIWebView.