我在长按和双击手势上显示 UIMenuController,但它没有显示。我已经按照这里给出的答案,但它仍然没有出现。UIMenuController 没有出现
下面是我的代码
- (void) doubleTap:(UITapGestureRecognizer *)gesture
{
[self becomeFirstResponder];
CGPoint location = [gesture locationInView:[gesture view]];
UIMenuController *menuController = [UIMenuController sharedMenuController];
UIMenuItem *resetMenuItem = [[UIMenuItem alloc] initWithTitle:@"DoubleTap" action:@selector(hideKeyboard)];
[menuController setMenuItems:[NSArray arrayWithObject:resetMenuItem]];
[menuController setTargetRect:CGRectMake(location.x, location.y, 0.0f, 0.0f) inView:[gesture view]];
[menuController setMenuVisible:YES animated:YES];
}
- (void) longPress:(UITapGestureRecognizer *)gesture
{
[self becomeFirstResponder];
CGPoint location = [gesture locationInView:[gesture view]];
UIMenuController *menuController = [UIMenuController sharedMenuController];
UIMenuItem *resetMenuItem = [[UIMenuItem alloc] initWithTitle:@"LongPress" action:@selector(hideKeyboard)];
[menuController setMenuItems:[NSArray arrayWithObject:resetMenuItem]];
[menuController setTargetRect:CGRectMake(location.x, location.y, 0.0f, 0.0f) inView:[gesture view]];
[menuController setMenuVisible:YES animated:YES];
}
- (BOOL)becomeFirstResponder
{
return YES;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:))
{
return YES;
}
return [super canPerformAction:action withSender:sender];
}
我正在尝试在 tableView 的 didSelectRow 上获取此事件,可以穿什么。