I'm trying to get UIMenuController to display a menu.
Here is the code I have so far:
commentCell.userInteractionEnabled = YES;
[commentCell becomeFirstResponder];
UIMenuController *menu = [UIMenuController sharedMenuController];
if (menu.menuVisible) {
return;
}
menu.menuItems = @[[[UIMenuItem alloc] initWithTitle:@"copy" action:@selector(log)], [[UIMenuItem alloc] initWithTitle:@"report" action:@selector(log)]];
const CGRect targetFrame = commentCell.frame;
const CGRect convertedFrame = [commentCell convertRect:targetFrame toView:self.viewController.view];
[menu setTargetRect:convertedFrame inView:self.viewController.view];
[menu update];
[menu setMenuVisible:YES animated:YES];
Unfortunately, it seems that my menu is not displaying. I tried to follow the guidelines outlined in: UIMenuController not showing up but I've already tried all the suggestions including making my view implement canBecomeFirstResponder
and setting userInteractionEnabled
to YES
. Any ideas what might be the issue or how I can debug further?