我的客户报告了一个基本 UIMenuController 的奇怪行为:当应用程序从应用商店或临时安装时,UIMenuController 不会出现!它在模拟器上运行良好,或者直接从 xcode 加载时,但如果我尝试分发完全相同的应用程序并通过应用程序商店或 ipa 文件安装它,菜单不会显示。
这可能是从哪里来的?
我认为它没有帮助,但这是我用来显示菜单控制器的代码:
UIMenuController *menuController;
NSAssert([self becomeFirstResponder], @"Sorry, UIMenuController will not work with %@ since it cannot become first responder", self);
UIMenuItem *duplicateItem = [[UIMenuItem alloc] initWithTitle:@"Duplicate" action:@selector(duplicate:)];
UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:@"Delete" action:@selector(deleteButton:)];
UIMenuItem *copyItem = [[UIMenuItem alloc] initWithTitle:@"Copy" action:@selector(copySelected:)];
[menuController setMenuItems:[NSArray arrayWithObjects:duplicateItem, deleteItem, copyItem, nil]];
[menuController setArrowDirection:UIMenuControllerArrowDown];
[menuController setTargetRect:sender.frame inView:contentView];
[menuController setMenuVisible:YES animated:YES];
和 :
- (BOOL) canPerformAction:(SEL)selector withSender:(id) sender
{
return [super canPerformAction:selector withSender:sender];
}