wibosco
wibosco

Reputation: 967

Disable paste in uitextfield in iOS5

I'm attempting to disable paste in a textfield using the following code:

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

  if ([UIMenuController sharedMenuController]) {

    [UIMenuController sharedMenuController].menuVisible = NO;

  }

  return NO;
}

I've this code in other projects and its worked, however in my current project it just gets called multiple times and then displays the paste menu item.

This only thing that I can see that is different is that in this project the viewcontroller where the above code lives is the child of a custom viewcontroller.

EDIT

It's not showing the menu option when I run it with in the simulator with iOS4.3 as opposed to iOS5

Upvotes: 0

Views: 3657

Answers (1)

wibosco
wibosco

Reputation: 967

I got there in the end. Instead of placing the code into the viewcontroller, i subclassed UITextField and placed it in there and it works.

I based it on the example here:

How do you REALLY remove Copy from UIMenuController

Upvotes: 3

Related Questions