I want to add an extra menu item to the menu that appears when any text is selected.
I added the code below viewDidLoad:
NSMutableArray *extraItems = [[NSMutableArray alloc] init];
UIMenuItem *boldItem = [[UIMenuItem alloc] initWithTitle:@"Bold"
action:@selector(bold:)];
[extraItems addObject:boldItem];
[UIMenuController sharedMenuController].menuItems = extraItems;
I have also rewritten my UIWebView user interface in the following ways:
- (void)bold:(id)sender {
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == @selector(bold:))
return YES;
return [super canPerformAction:action
withSender:sender];
}
Therefore, sometimes, when I select text, the menu pacifies, but sometimes it is not. I do not know what the problem is.
source
share