jimt
jimt

Reputation: 2010

Customize 'Copy' text popup (UIWebView)?

I'm trying to customize the user text selection behavior in a UIWebView. Currently, when a user highlights a region of text in a UIWebView the 'Copy' action sheet appears, allowing you to copy the text. I would like to perform some custom action on text selection, effectively replacing the 'Copy' dialog, or adding another option to the list of options (e.g. 'Copy' | 'Search').

My question is: Is there any Apple-accepted way of doing this? I'd prefer not to put my app approval in jeopardy, so doing this by the book is ideal. I've seen similar questions asked about this topic, but all remain unanswered. Can anyone provide some insight on how to accomplish this?

Upvotes: 0

Views: 2612

Answers (1)

Benjamin Mayo
Benjamin Mayo

Reputation: 6679

The popup you refer to is called a UIMenuController. You can access the [UIMenuController sharedMenuController] method to get the menu controller. You can then add your own UIMenuItems to the menu controller, and these can be shown contextually, using the canPerformAction:withSender: method on the UIWebView. For more info, refer to the iOS Developer Reference on UIMenuController

Upvotes: 2

Related Questions