Override iPhone copy menu captions on a long-press?

房东的猫 提交于 2019-12-25 04:55:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!