Search code examples
ios5uiwebviewuimenucontroller

Handle to "Copy" & "Define" Popover Menu Items


Trying to do some work with text selected in a UIWebView. There are 2 buttons that pop over:

Copy and Define

enter image description here

At a very high level, how can I do the following?

1) Grab the value of the text selected

2) Add another menu item

Thanks


Solution

  • The UIMenuController singleton is the black popup with the buttons, and the documentation has good information on how to work with that (presenting it manually, adding new items, responding to actions, etc).

    As for getting the selected text, I see you're using an editable div in a UIWebView, which means you have to respond to editing actions via JavaScript.