问题
Is it possible to override the captions in the "Copy" menu when the iphone user long-presses on some text? Essentially, I'd like to change the text to something like "Create a Note" instead of "Copy". Is that possible?
回答1:
You can add custom menus via UIMenuController's menuItems property, something like:
UIMenuItem* item1 = [[UIMenuItem alloc] initWithTitle:@"One" action:@selector(DoThingOne:)];
UIMenuItem* item2 = [[UIMenuItem alloc] initWithTitle:@"Two" action:@selector(DoThingTwo:)];
[UIMenuController sharedMenuController].menuItems = [[[NSArray alloc] initWithObjects:item1, item2, nil] autorelease];
[item1 release];
[item2 release];
However, this is only in iPhone OS 3.2, which would make it iPad only at this point. There's an example here (scroll down to "Custom Edit Menu Items").
As for altering the existing items, I do not believe that is possible currently.
来源:https://stackoverflow.com/questions/2760897/override-iphone-copy-menu-captions-on-a-long-press