Post

Replies

Boosts

Views

Activity

How to create custom edit menu and remove the default edit menu which is shown in pdfView for iOS 16
I am not getting any action callback on the default Highlight edit menu, when selecting the text and pressing the Highlight edit 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 UIEditMenuIntraction to add a new edit menu since in iOS 16 UIMenuController is 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 UIMenuBuilder and 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 canPerformAction method to get the action callback of default Highlight edit menus and tried to the removed default edit menus by returning No but no luck. - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { BOOL can = [super canPerformAction:action withSender:sender]; return NO; }
2
1
1.1k
Jul ’23