Questions tagged [uimenucontroller]

The singleton UIMenuController instance presents the menu interface for the Cut, Copy, Paste, Select, Select All, and Delete commands. This menu is referred to as the editing menu. When you make this menu visible, UIMenuController positions it relative to a target rectangle on the screen; this rectangle usually defines a selection. The menu appears above the target rectangle or, if there is not enough space for it, below it.

The singleton UIMenuController instance presents an Editing Menu. You can create an instance like this

    UIMenuController *menuController = [UIMenuController sharedMenuController]; 

You can position it relative to a target rectangle on the screen which usually defines a selection.

An example implementation of UIMenuController (assuming you are coding for at least iOS 3.2 ()):

    UIMenuController *menuController = [UIMenuController sharedMenuController];
    UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"title" action:@selector(aMethod:)];
    UIMenuItem *menuItem1 = [[UIMenuItem alloc] initWithTitle:@"title" action:@selector(anotherMethod:)];
    [menuController setMenuItems:[NSArray arrayWithObjects:menuItem, menuItem1, nil]];
    [menuController setTargetRect:CGRectMake(location.x, location.y, 0, 0) inView: someView];
    [menuController setMenuVisible:YES animated:YES];
    menuController.arrowDirection= UIMenuControllerArrowLeft; 
    [resetMenuItem release];

References:

269 questions
66
votes
7 answers

UIMenuController not showing up

I'm trying to create a custom UIMenuController and display it in my view. Here's my code: UIMenuController *menuController = [UIMenuController sharedMenuController]; UIMenuItem *listMenuItem = [[UIMenuItem alloc] initWithTitle:@"List"…
indragie
  • 17,634
  • 15
  • 89
  • 161
24
votes
4 answers

How to show a custom UIMenuItem for a UITableViewCell?

I want the UIMenuController that pops up when I long-press a UITableViewCell to show custom UIMenuItems. I set up the custom item in viewDidLoad UIMenuItem *testMenuItem = [[UIMenuItem alloc] initWithTitle:@"Test"…
leberwurstsaft
  • 385
  • 1
  • 3
  • 11
22
votes
2 answers

How could I replace UIMenuController with my own view when text is selected?

When text is selected, by default a UIMenuController pops up with cut/copy/paste etc. I'd like to replace this with my own custom view (similar looking, but twice as high so that I can have two rows of buttons/custom views). How can I do this? I…
Jordan Smith
  • 10,122
  • 7
  • 63
  • 111
21
votes
6 answers

How do you REALLY remove Copy from UIMenuController

There apparently used to be an easy way to prevent the "More..." label from appearing in UIMenuController when you added more than one custom menu item. You just had to remove all of the system menu items. There was even a workaround here for still…
lfalin
  • 3,849
  • 5
  • 27
  • 52
21
votes
2 answers

showing custom menu on selection in UIWebView in iphone

I want to show 2 options like "hi" & "bye" when user completes selection on UIWebView. I have added observer to my view controller as follows. But I don't know further implementation. [[UIMenuController sharedMenuController] addObserver:self …
Sagar R. Kothari
  • 23,587
  • 48
  • 158
  • 226
19
votes
12 answers

Disable entire UIMenuController edit menu in WKWebView

Requirement I have a WKWebView and would like to remove the system menu items (Copy, Define, Share...) from the Edit Menu and present my own. I am targeting iOS 8 and 9. I am currently testing with the Xcode 7.0.1 simulator (iOS 9) and my iPhone 6…
davew
  • 1,146
  • 13
  • 27
19
votes
9 answers

How to get UIMenuController work for a custom view?

I'm trying to get the following code work: UIMenuController * menu = [UIMenuController sharedMenuController]; [menu setTargetRect: CGRectMake(100, 100, 100, 100) inView: self.view]; [menu setMenuVisible: YES animated: YES]; The menu instance is…
al_lea
  • 574
  • 1
  • 8
  • 17
17
votes
4 answers

Determine when a UIMenuController is dismissed?

Is there a way to determine when a UIMenuController has been dismissed? I have a (non-editable) text area I'm highlighting when the menu is brought up, and I'd like to un-highlight it when they either select an item (easy) or cancel (not possible?)
Ben Gottlieb
  • 84,498
  • 22
  • 171
  • 170
14
votes
1 answer

UIMenuController Custom Items

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"…
Joshua
  • 14,412
  • 21
  • 96
  • 171
12
votes
2 answers

Connection to daemon was invalidated

My app is using Firebase Analytics and I believe starting in iOS 13.2 started getting the errors described here: Why I get the console warning: [Process] kill() returned unexpected error 1 when I load a WKWebView in iOS13.2? I guess it wasn't a big…
Ebarella
  • 153
  • 1
  • 2
  • 8
12
votes
2 answers

UIMenuController Editing Menu in UIWebView only appears second time

I am finding that in my app in iOS 9, when I long press in a UIWebView, the editing menu that normally appears, only appears the second (and following) times that I long press. The first time I long press in any particular webview no menu at all…
narco
  • 750
  • 4
  • 20
11
votes
1 answer

UIMenuController method setTargetRect:inView: not working in UITableView

I am displaying custom UIMenuController in my tableview like this but issue is that it is displaying in the center I want to display it on top of label which is orange colored. For displaying on top of label I did this [menu…
S.J
  • 2,979
  • 3
  • 30
  • 63
11
votes
1 answer

Text color in UIMenuController affected by UIButton appearance setting

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…
yinkou
  • 5,726
  • 2
  • 21
  • 40
11
votes
1 answer

How to add custom menu item to UITextView menu, which is a link to the Wikipedia page of the selected word?

I am new to Xcode, I am using version 4.6.3 - Macbook too old for the new version. I looked around the internet and Stack Overflow and cannot find what I want or I cannot get snippets to work. I would like to add a menu item to the menu items that…
user2963333
  • 135
  • 1
  • 6
10
votes
4 answers

Problems showing UIMenuController one after another

I'm using the new customization abilities of the UIMenuController to add things other than "Copy" to the menu for cut&paste into a webview. What I do is getting the reference to the shared UIMenuController, setting my NSArray of UIMenuItems into the…
sissensio
  • 103
  • 1
  • 5
1
2 3
17 18