uimenucontroller

Removing Copy, Look Up, and Share from UIMenuController

旧时模样 提交于 2019-12-11 03:25:57
问题 I am trying to override the default UIMenuController so that only my custom item "Define..." appears when the user selects text in its text view. I haven't had much luck with the approaches I've found online thus far. To be more specific, I have subclassed a UIViewController and used canPerformAction() to exclude all actions except my define method. override func becomeFirstResponder() -> Bool { return true } override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool

how to disable UIMenuControll (cut,copy,paste,select all,delete) in UIviewController subclass?

落爺英雄遲暮 提交于 2019-12-08 13:28:45
问题 i have implemented many methods but paste doesn't hide. i am using Xcode Version 4.5.2 -(BOOL)canPerformAction:(SEL)action withSender:(id)sender { UIMenuController *menuController = [UIMenuController sharedMenuController]; if (menuController) { [UIMenuController sharedMenuController].menuVisible = NO; } return NO; } every method is seems to fail working for me. can anybody help me on this? thanks in advance 回答1: You need to do these things to enable/disable UIMenuController items. To show

Order of UIMenuItems in custom edit menu

烂漫一生 提交于 2019-12-08 12:05:39
问题 I want to add my own commands to the selection menu, but also keep the standard "copy", "cut", etc. commands. I use this: UIMenuItem *myItem = [[UIMenuItem alloc] initWithTitle:@"My Command" action:@selector(myCommand:)]; [[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObjects: myItem, nil]]; But this adds my command to the very end of the list in the edit menu. I want my command to appear first in it. How could I achieve this? 回答1: Solved it by myself. Here is what in

Can I subclass UIMenuController so that it can take icons instead of just text?

倾然丶 夕夏残阳落幕 提交于 2019-12-08 09:21:34
问题 How would one go about doing this? I'm looking for a dense, purely graphical menu on tap-hold. 回答1: In 3.2 you can add menu items using the menuItems property. But I think subclassing won't be useful, since it's a singleton that does not returns the views of each menu item. You could access menuFrame when setMenuVisible:animated: is called, so you can add you're own view that looks like a menu items with icons. But for adding icons to the system menu items... I think you should stick to what

Hide Copy and Deselect UITextView options after copying all text

南楼画角 提交于 2019-12-07 12:30:06
问题 I am working on a messaging app. I want to give a "copy" option to the user when they enter their message in a UITextView . When the user presses the "copy" button, it is copying the message, but the popover shows again and again, and the text is still selectable. I don't know how to control this. I have pasted some source code for your reference. I wrote a sub class for UITextView . - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { NSLog(@"Action : %@", NSStringFromSelector(action

UITEXTVIEW: Get the recent word typed in uitextview

北慕城南 提交于 2019-12-07 11:43:37
问题 I want to get the most recent word entered by the user from the UITextView. The user can enter a word anywhere in the UITextView, in the middle or in the end or in the beginning. I would consider it a word when the user finishes typing it and presses a space and does any corrections using the "Suggestions from the UIMenuController ". Example: User types in "kimd" in the UITextView somewhere in the middle of text, he gets a popup for autocorrection "kind" which he does. After he does that, I

Pass value through UIMenuItem of UIMenuController

天大地大妈咪最大 提交于 2019-12-07 08:56:58
问题 I am using following method to show menu on long press in UITableViewCell. I have need to pass a value pressing Delete menu Item to -(void)numberDelete method. -(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer { if(gestureRecognizer.state == UIGestureRecognizerStateBegan) { CGPoint p = [gestureRecognizer locationInView: self.pullTableView]; NSIndexPath *indexPath = [self.pullTableView indexPathForRowAtPoint:p]; if(indexPath != nil) { [self becomeFirstResponder];

Text color in UIMenuController affected by UIButton appearance setting

99封情书 提交于 2019-12-06 22:32:27
问题 I've observed following: By setting the Titlecolor of a UIButton with appearance, the UIMenuItems in a UIMenuController of a UITextView are getting the same color. Code in applicationDidFinishLaunching : [[UIButton appearance] setTitleColor:[UIColor greenColor] forState:UIControlStateNormal]; My question: Is there a way to suppress it or give a UIMenuItems another color? What i have tried: With appearanceWhenContainedIn UITextview I've tried to set the appearance for buttons contained in

How do Prevent a copy/paste/select popover on a UITextView using UIMenuController iOS5.1

╄→尐↘猪︶ㄣ 提交于 2019-12-06 16:09:11
问题 The question : How do I prevent the copy/paste/select popup that occurs over a UITextView from appearing (not using UIwebView and css)? I did not want to go the rout of UIWebView as some posts have gone because I already am using UIViews with UITextFields for data entry. I had tried unsuccessfully to implement the solutions dealing with UITextField in my implementation file of my view controller with the methods: targetForAction:withSender , setMenuVisible:animated and finally

UIMenuController not getting displayed

我与影子孤独终老i 提交于 2019-12-06 06:48:17
问题 I am displaying UIMenuController on long press & double tap gesture, but its not getting displayed. I have followed the answers given here but it still not showing up. UIMenuController not showing up Below is my code - (void) doubleTap:(UITapGestureRecognizer *)gesture { [self becomeFirstResponder]; CGPoint location = [gesture locationInView:[gesture view]]; UIMenuController *menuController = [UIMenuController sharedMenuController]; UIMenuItem *resetMenuItem = [[UIMenuItem alloc]