facing trouble while using uimenucontroller
I need to use uimenucontroller in my app, where i want copy/paste/etc options, when ever i move any selected uiview/uiimageView present in uiviewcontroller.
here is the code i am using:
{
UIMenuController *menuController = [UIMenuController shared开发者_如何学运维MenuController];
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 am calling this function in touches end in uiviewcontroller, which is pushed from rootviewcontroller, uimenucontroller is showing only at the first use of viewcontroller, when ever i go back to rootviewcontroller and pushing the uiviewcontroller , uimenucontroller is not showing menu items at touches ended. and i can find that
[self becomeFirstResponder];
returning NO value.. can any one help me to solve this problem.
Your view or view controller needs to implement -(BOOL)canBecomeFirstResponder (returning YES)
精彩评论