我有一个气球视图,当我点击单元格UIMenuController时没有出现。我试图在
中实施
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath,
然后我添加了一个长按手势
- (void)longPress:(UILongPressGestureRecognizer *)识别器,
最后我在扩展
中添加了一个实现的UITableViewCell
课程,但它仍然不起作用。
这是一个例子
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (BOOL) canPerformAction:(SEL)selector withSender:(id) sender
{
return YES;
}
-(void)copyAction:(id)sender{
NSLog(@"copy");
}
-(void)deleteAction:(id)sender{
NSLog(@"delete");
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
BalloonCell *cell = (BalloonCell*)[tableView cellForRowAtIndexPath:indexPath];
[self becomeFirstResponder];
BOOL isCanBecomde = [self canBecomeFirstResponder];
BOOL isFirst = [self isFirstResponder];
UIMenuItem *copy = [[UIMenuItem alloc] initWithTitle:@"Копировать" action:@selector(copyAction:)];
UIMenuItem *delete = [[UIMenuItem alloc] initWithTitle:@"Удалить" action:@selector(deleteAction:)];
UIMenuController *menu = [UIMenuController sharedMenuController];
CGRect drawRect = [cell convertRect:cell.bounds toView:self.view];
[menu setTargetRect:drawRect inView:window];
[menu setMenuItems:[NSArray arrayWithObjects:copy, delete, nil]];
[menu setMenuVisible:YES animated:YES];
}
你有没有猜到为什么没有出现UIMenuController?