简体   繁体   中英

UIMenuController not showing custom UIMenuItem in subclassed UITextView

I have a subclassed UITextView that I would like to show a custom UIMenuItem when a user pressed and holds in the UITextView . For the life of me, I cannot get my custom item to show. Here is what I am doing in viewDidLoad :

UIMenuItem *customMenuItem1 = [[UIMenuItem alloc] initWithTitle:@"Keywords" action:@selector(insertKeywords)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:customMenuItem1]];

Pressing and holding in my subclases UITextView I still only see "Select" and "Select All".

What do I need to do to also show my custom item?

Figured it out. I had never implemented the insertKeywords method, so the UIMenuItem was never shown!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM