Facing a problem when using uimenucontroller

I need to use the uimenucontroller in my application, where I need the copy / paste / etc options when ever I move any selected uiview / uiimageView present in the uiviewcontroller.

here is the code i use:

{ UIMenuController *menuController = [UIMenuController sharedMenuController]; UIMenuItem *resetMenuItem = [[UIMenuItem alloc] initWithTitle:@"Paste" action:@selector(menuItemClicked:)]; [self becomeFirstResponder]; [menuController setMenuItems:[NSArray arrayWithObject:resetMenuItem]]; [menuController setTargetRect:imageView.frame inView:self.view]; [menuController setMenuVisible:YES animated:YES]; } 

I finally call this function in the uiviewcontroller that pops out of the rootviewcontroller, the uimenucontroller only shows when I use the viewcontroller for the first time, when I return to the rootviewcontroller and click on the uiviewcontroller, the uimenucontroller does not show the menu items the touches are over. and i can find that

  [self becomeFirstResponder]; 

return value NO. can anyone help me solve this problem.

+4
source share
1 answer

The view or view controller must implement - (BOOL) canBecomeFirstResponder (return YES)

0
source

All Articles