I am developing an app that supports editing attributedText in a UITextView. To provide the tools to the user for formatting their input, I am using an inputAccessoryView to augment the keyboard with options like bullet list, numbered list, indent, outdent, font controls (bold, underline, increase fontsize, decrease font size), etc. This is too much to fit on the inputAccessoryView so I am looking to use the UIMenuController to provide a mechanism to provide more space for the user to make their intentions known.
So, I have a inputAccessoryView with a 'listAccessory' button. When it is pressed, I wanted to show a UIMenuController with four options (bullet, number, increase indent, decrease indent). But when I show this menu, it ALSO includes 'select', 'selectAll' and 'paste'.
I do not have any of these methods (select:, selectAll:, or paste: as defined in the UIResponderStandardEditActions informal protocol) defined in my view. I have defined canPerformAction:withSender: and only respond with 'YES' for my selectors.
- (BOOL) canPerformAction:(SEL)selector withSender:(id) sender
{
DDLogInfo(@"canPerformAction: %@", NSStringFromSelector(selector));
if (selector == @selector(formatAsBulletList:)) return YES;
if (selector == @selector(formatAsNumberedList:)) return YES;
if (selector == @selector(formatIncreaseIndent:)) return YES;
if (selector == @selector(formatDecreaseIndent:)) return YES;
return NO; // return [super canPerformAction:selector withSender:sender];
}
When I log the selectors being called in this code, I don't see any request for 'select:', 'selectAll:', or 'paste:', so I believe that the UIMenuController code is testing for those methods with direct calls to canPerformSelector() against the class.
Since I don't implement those functions in my viewController (derived from UITableViewController), I can only believe surmise that the UIMenuController is looking up the responder chain and seeing that the responder that initiatated the keyboard initially is a UITextView, which DOES support select, selectAll, and paste.
So I have a couple of questions:
1) is my understanding of the situation right?
2) how do I force those menu items to not appear? Can I somehow temporarily break the responder chain without dismissing the keyboard?