UIContextMenu in Wrong Place

I am presenting a IUContextMenu on a UIImageView but it always shows up in the right upper hand corner of the image and not at the place touched on the UIImageView (i.e. "location"). The coordinates for "location" are correct but the menu still shows up in the right upper hand corner of the UIImageView. Project built in XCode 11 Beta 6. I can't figure out why.


- (nullable UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction configurationForMenuAtLocation:(CGPoint)location {
    
    UIContextMenuConfiguration *configuration = [UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:nil actionProvider:^UIMenu * _Nullable(NSArray<UIMenuElement *> * _Nonnull suggestedActions) {
        
        return [self makeContextMenu];
        
    }];
    
    return configuration;
}

- (UIMenu *)makeContextMenu {
    UIAction *copy = [UIAction actionWithTitle:@"Copy Image" image:[UIImage systemImageNamed:@"doc.on.doc"] identifier:nil handler:^(__kindof UIAction * _Nonnull action) {
        
        [self performSelector:@selector(performCopy) withObject:nil afterDelay:1.0];
    }];
    
    return [UIMenu menuWithTitle:@"" children:@[copy]];
}

- (void)performCopy {
  UIPasteboard *appPasteBoard = [UIPasteboard generalPasteboard];
  appPasteBoard.image = imageView.image;
}

Replies

And the following code is located in ViewDidLoad:


- (void)viewDidLoad {
    interaction = [[UIContextMenuInteraction alloc] initWithDelegate:self];
    [imageView addInteraction:interaction];
}