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:

277 questions
10
votes
2 answers

Dynamic UIMenuItems with @selector and dynamic methods

I am trying to use UIMenuController for a dynamical menu (titles and actions come from a server). The problem is that I have to use UIMenuItems initWithTitle:action: where action is a @selector. I can use @selector(dispatch:) but then I am not able…
Jeena
  • 2,172
  • 3
  • 27
  • 46
10
votes
2 answers

WKWebView and UIMenuController

I have an app with a WKWebView in it. In this app, I customize the options presented in the UIMenuController. The web view seems to add Copy and Define options to the menu no matter what I do. If I set myself as first responder and return NO for…
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
9
votes
4 answers

IOS UIMenuController UIMenuItem, how to determine item selected with generic selector method

With the following setup .... MyUIMenuItem *someAction = [[MyUIMenuItem alloc]initWithTitle : @"Something" action : @selector(menuItemSelected:)]; MyUIMenuItem *someAction2 = [[MyUIMenuItem alloc]initWithTitle : @"Something2" action :…
ort11
  • 3,359
  • 4
  • 36
  • 69
8
votes
2 answers

Showing UIMenuController loses keyboard

I'm making an iphone app similar to the Messages app that comes on the phone. I just set up the ability to copy messages via a UIMenuController, but if the keyboard is showing and someone tries to copy a message, the keyboard goes away (presumably…
Stephen
  • 741
  • 8
  • 18
8
votes
2 answers

Context Menus in PDFs

Built into UIWebView and QLPreviewController is the ability to highlight text and present some manner of context menu to the user. While presenting the menu is the trivial part, determining the bounding rects of the lints of the PDF is beyond me. …
CodaFi
  • 43,043
  • 8
  • 107
  • 153
8
votes
1 answer

Second UIMenuController not Hiding

Tapping the cursor in a UITextView brings up a UIMenuController. Tapping Select causes the relevant text to be selected and another UIMenuController with new options to be displayed. Tapping anywhere else in the text view causes the "second"…
CyberMoai
  • 496
  • 3
  • 11
8
votes
4 answers

UIMenuController sharedMenuController - custom menuitem for uicollectionview do not show in ios 7

I'm using a UIMenuItem to perform a custom action in UICollectionView cell long press. this worked perfectly with iOS 6, but now I am converting my application to iOS 7 and Xcode 5 and it don't work. The custom item do not shown. UIMenuItem…
Raw
  • 139
  • 1
  • 2
  • 6
7
votes
1 answer

how to create Custom UIMenuController with only custom items other than default?

I have requirement to show menu items on uiwebview whenever user selects any text. I have tried let highlightMenuItem = UIMenuItem(title: "Highlight", action:…
Nitesh
  • 1,924
  • 21
  • 31
7
votes
2 answers

How to enable UITextView to receive pasted images

I need to support pasting of images into a UITextView. With an image copied to the clipboard, the "Paste" option doesn't seem to pop up. It does when there's text on the clipboard. This is how to override the paste option in a custom UITextView. But…
Matt Koala
  • 2,171
  • 2
  • 18
  • 14
7
votes
1 answer

Implementing iphone's copy/paste controls on a custom view / uiview subclass

I will admit that there is already a question exactly along these lines here on S.O., but it lacks implementation details, a working answer, and I would like to be more specific, so I think a new question is in order. Obviously, let me know if I'm…
Billy Gray
  • 1,747
  • 4
  • 18
  • 23
7
votes
2 answers

_UIFallbackPresentationViewController

I keep getting the following error when I dismiss the dictionary that opens from tapping Define on the UIMenuController in a UIWebView on the iPhone:- Unbalanced calls to begin/end appearance transitions for <_UIFallbackPresentationViewController:…
Sam J.
  • 685
  • 1
  • 8
  • 22
6
votes
3 answers

iOS: How to get the selected UIMenuItem from UIMenuController

I am trying to use UIMenuCnotroller to show a list of dynamically generated items, they share the same action method, and so I need to know which item is selected in the single action method. However, in the action method -…
Hao Gong
  • 63
  • 1
  • 3
6
votes
5 answers

Disable copy, paste in UITextfield is not working in iOS 9.x

I created a text field in one class BBCustomUtility.h,.m class files and then +(UITextField*)createTextField: (CGRect)rect image:(NSString*)imageName tag:(int)tag secureText:(BOOL)entry placeh:(NSString*)placeholder { UITextField…
6
votes
4 answers

UIMenuController is getting dismissed immediately after being presented

I have subclassed UIWebView to add custom UIMenuController functionality in and it was working pretty well up until iOS 9. I am not sure what has changed, but now I am running into a situation where when I tap on a link, that should present the…
Lizza
  • 2,769
  • 5
  • 39
  • 72
6
votes
6 answers

UIMenuController with custom item not working with UICollectionview

I have added custom menu controller when long press on UICollectionViewCell [self becomeFirstResponder]; UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Custom Action" …
Heena
  • 2,348
  • 3
  • 32
  • 58
1
2
3
18 19