iPhone – Disable the Cut/Copy/Paste Menu on UITextField

Update @ 2012-07-11: for ios >= 5.1 canPerformAction:(SEL)action withSender:(id)sender is not working anymore. Please refer to the following post for more information
StackOverflow – How do you REALLY remove Copy from UIMenuController

 

If you want to disable the Cut/Copy/Paste Menu, add the following piece of code in the implementation file of the view controller which containing the UITextField

-(BOOL)canPerformAction:(SEL)action withSender:(id)sender {
	UIMenuController *menuController = [UIMenuController sharedMenuController];
	if (menuController) {
		[UIMenuController sharedMenuController].menuVisible = NO;
	}
	return NO;
} 

 

It overrides the canPerformAction:withSender method of the UIResponder class.

Done =)

Reference: How to disable Cut, Copy and paste feature

14 thoughts on “iPhone – Disable the Cut/Copy/Paste Menu on UITextField”

    1. i submitted the app last week and it is not yet approved. let u know after i get the reply from Apple. =)

      Like

  1. This is not working for me!
    I just pasted your code in my project’s Registration form. (I have class RegistrationForm that subclasses UIViewController)
    On this class’ XIB, I have 4 UITextFields.
    1. Master Password UITextField
    2. Re-enter Master Password UITextField
    3. Email ID UITextField
    4. Re-enter Email ID UITextField

    Now, I don’t want users to copy or paste or select text on these text fields.

    I just pasted the above code in my implementation file – RegistrationForm.m

    But, it is not working. I am able to see the floating Copy, cut, paste menu and also perform the same actions.

    Please help me!

    Chandra

    Like

      1. Thanks ykyuen, for your prompt reply! And also, thanks for other alternate solution.

        Chandra

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.