UIMenuController in keyboard extension

320 Views Asked by At

I need to show UIMenuController with 2 actions in my keyboard extension. It must appear when user click on button on collection view's cell (cell.textButton in code)

When I'm trying to show it all my keyboard view controller becomes grey, without crash: enter image description here

Here is a code:

UIMenuItem *actionCopy = [[UIMenuItem alloc] initWithTitle:@"someaction1" action:@selector(action1)];
UIMenuItem *actionDefine = [[UIMenuItem alloc] initWithTitle:@"someaction2" action:@selector(action2:)];
    
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setMenuItems:[NSArray arrayWithObjects:actionCopy, actionDefine, nil]];
CGRect frame = [self.view convertRect:cell.textButton.frame fromView:cell.textButton];
[menu update];
[self becomeFirstResponder];
[menu setTargetRect:frame inView:self.view];
[menu setMenuVisible:YES animated:YES];

Did someone try to add UIMenuController to keyboard extension? thanks

0

There are 0 best solutions below