0

I have a UITextField that contains code to activate an app. For that UITextField, I want the Copy option only. I can do this by overriding canPerformAction:withSender:

However I want to know, is there any IBAction or delegate which will tell me that copying is done?

What I want to do is after clicking Copy, I directly want to go to screen where I will paste the code and get the app activated.

Any idea how to get this done?

Community
  • 1
  • 1
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276

1 Answers1

1

Make custom MenuController as following:

UIMenuItem *copy = [[UIMenuItem alloc] initWithTitle:@"copy" action:@selector(copy)];
UIMenuItem *paste = [[UIMenuItem alloc] initWithTitle:@"paste" action:@selector(paste)];
UIMenuItem *deleteAll = [[UIMenuItem alloc] initWithTitle:@"deleteAll" action:@selector(deleteAll)];

UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setMenuItems:[NSArray arrayWithObjects:copy, paste, deleteAll, nil]];

[menu setTargetRect:self.navigationController.navigationBar.frame inView:self.view];

[menu setMenuVisible:YES animated:YES];

In ViewDidLoad before initialising menu controller write this line [self canBecomeFirstResponder];

Hope this helps

iAhmed
  • 6,556
  • 2
  • 25
  • 31