UIMenuController Custom Items

Posted by Joshua on Stack Overflow See other posts from Stack Overflow or by Joshua
Published on 2010-08-21T13:24:47Z Indexed on 2012/10/02 3:38 UTC
Read the original article Hit count: 427

I have created a UIMenuController and have set it a custom menu item like so:

UIMenuController *menuController = [UIMenuController sharedMenuController];
UIMenuItem *item1 = [[UIMenuItem alloc] initWithTitle:@"Do This" action:@selector(item1)];
[menuController setMenuItems:[NSArray arrayWithObject:item1]];

But I wanted that object to be the only one to appear so I added this code:

- (BOOL)canPerformAction: (SEL)action withSender: (id)sender {
    BOOL answer = NO;

    if (action == @selector(item1))
        answer = YES;

    return answer;
}

The problem is it still shows other## Heading ## items, such as "Select", "Select All" and "Paste". This may have something to do with this being displayed in a UITextView. But how do I stop if from displaying all other items?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c