ios UIMenuController не работает с видом всплывающего окна
У меня есть вид шара, и когда я нажимаю на ячейку, 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 не появляется?