0

i have implemented many methods but paste doesn't hide. i am using Xcode Version 4.5.2

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

    }
    return NO;  
}

every method is seems to fail working for me. can anybody help me on this? thanks in advance

iAhmed
  • 6,556
  • 2
  • 25
  • 31
  • 1
    try to subclass your outlets - check my example for UITextFields http://stackoverflow.com/a/14582785/1702413 – TonyMkenu May 10 '13 at 21:41

2 Answers2

0

You can try this: in your controller's viewDidLoad method, set it to invisible.

[[UIMenuController sharedMenuController] setMenuVisible:NO];

If that does not work, I guess you are out of luck as it is part of the system. The only way I see is to disable the user interaction with objects that might trigger a context menu.

Mundi
  • 79,884
  • 17
  • 117
  • 140
0

You need to do these things to enable/disable UIMenuController items.

  1. To show/hide the UIMenuController items, your view or view controller needs to implement canBecomeFirstResponder(returning YES/NO for Show/Hide).

  2. You can also implement the canPerformAction:withSender: method of UIResponder to disable or enable user-interface commands {copy, select, select all, paste and etc} based on the context.

  3. Or you can override the Update method of UIMenuController to handle the custom behavior of an individual item. For example, if the pasteboard holds no data of a compatible type, the Paste command would be disabled. So you may either force to show/hide the paste menu item by overriding this method.

Deminem
  • 672
  • 8
  • 19