I am not getting any action callback on the default
Highlightedit menu, when selecting the text and pressing theHighlightedit menu, where do we get the callback of this edit menu?Also I am trying to remove this default edit menu and trying to add a set of new edit menus but some of the default edit menu is not getting removed. So how can we achieve this
Do we need to use
UIEditMenuIntractionto add a new edit menu since in iOS 16UIMenuControlleris deprecated, if yes then how to implement it on the text selection in pdfview.For iOS 16 I have tried to override the default edit menus using
UIMenuBuilderand added a few new edit menus as a sibling, but unable to remove the default edit menu ex-(`Highlight').
- (void)buildMenuWithBuilder:(id<UIMenuBuilder>)builder{
if (@available(iOS 16.0, *)) {
[builder removeMenuForIdentifier:UIMenuLookup];
[builder removeMenuForIdentifier:UIMenuReplace];
[builder removeMenuForIdentifier:UIMenuShare];
[builder removeMenuForIdentifier:UIMenuFormat];
// Add new .textStyle action
UIAction *testMenuItem = [UIAction actionWithTitle:@"Test" image:nil identifier:nil handler:^(UIAction *action){
NSLog(@"action callback");
}];
[builder replaceChildrenOfMenuForIdentifier:UIMenuStandardEdit fromChildrenBlock:^NSArray<UIMenuElement *> * _Nonnull(NSArray<UIMenuElement *> * _Nonnull existingChildren) {
NSMutableArray *children = [NSMutableArray arrayWithArray:existingChildren];
[children addObject:testMenuItem];
return children;
}];
}
[super buildMenuWithBuilder:builder];
}
- Also tried
canPerformActionmethod to get the action callback of default Highlight edit menus and tried to the removed default edit menus by returningNobut no luck.
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
BOOL can = [super canPerformAction:action withSender:sender];
return NO;
}