键盘扩展中的UIMenuController

时间:2014-11-25 11:51:01

标签: ios uicollectionview ios-keyboard-extension ios-extensions

我需要在键盘扩展中向UIMenuController显示2个动作。当用户单击集合视图单元格上的按钮(代码中的cell.textButton)

时,它必须出现

当我试图显示它时,我的键盘视图控制器变为灰色,没有崩溃: enter image description here

这是一段代码:

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];

是否有人尝试将UIMenuController添加到键盘扩展程序? 感谢

0 个答案:

没有答案