我长按和双击手势显示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这种情况下,有什么可以拨错。