Jeff
Jeff

Reputation: 1403

How to remove unwanted UIMenuItems from UITextfields UIMenuController?

In my application I am showing a UIMenuController with menus share, delete, etc for a UITableViewCell long press gesture.

It works perfectly, but after showing the menu, the default UIMenuController of UITextfield also has copy, paste, select menu items.

How do I remove these 'standard' menu items?

Upvotes: 2

Views: 203

Answers (2)

freelancer
freelancer

Reputation: 1658

Override the method of UITextfield as below

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
return NO;
}

Upvotes: 0

ahmedalkaff
ahmedalkaff

Reputation: 313

You should implement the method

- (BOOL)canPerformAction:(SEL)action
              withSender:(id)sender

and return YES for actions you want and NO for actions you don't want.

Upvotes: 1

Related Questions