I want to add additional menu item for the menu that appears when some text is selected.
I have added the code below to viewDidLoad
:
NSMutableArray *extraItems = [[NSMutableArray alloc] init];
UIMenuItem *boldItem = [[UIMenuItem alloc] initWithTitle:@"Bold"
action:@selector(bold:)];
[extraItems addObject:boldItem];
[UIMenuController sharedMenuController].menuItems = extraItems;
I also have overwritten my custom UIWebView with these methods:
- (void)bold:(id)sender {
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == @selector(bold:))
return YES;
return [super canPerformAction:action
withSender:sender];
}
So sometimes when I highlight the text the menu appeasers, but sometimes it does not. I don't know what the problem is.