Monday, November 2, 2015

How to disable "SELECT", "COPY", "PASTE"...etc

Hi Guys i came up with this scenario where i need to disable to the select,copy,paste ...etc menu view and found the best way to disable the menu as below

-(BOOL)canPerformAction:(SEL)action withSender:(id)sender{
      [[NSOperationQueue mainQueue] addOperationWithBlock:^{
      [[UIMenuController sharedMenuController] setMenuVisible:NO             
        animated:NO];
      }];
  return [super canPerformAction:action withSender:sender];
}

If you would like to disable the menu(select,selectall,copy...) for the entire view use above code, if needed for a particular control create a new class by subclassing it and add this method.

No comments:

Post a Comment