iOS Guides | Samples

MonoTouch.UIKit.UIMenuItem Class

Creates menu items that are attached to the editing menu.

See Also: UIMenuItem


[MonoTouch.Foundation.Register("UIMenuItem", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 3, 2, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
[MonoTouch.ObjCRuntime.Unavailable(MonoTouch.ObjCRuntime.PlatformName.TvOS, MonoTouch.ObjCRuntime.PlatformArchitecture.All, null)]
public class UIMenuItem : NSObject


UIMenuItems are menu items that appear on the editing menu after the system menu items. UIMenuItems are managed by a UIMenuController and should be added to that object's UIMenuController.MenuItems property.

As the following code, taken from the "Touches_GestureRecognizer" sample demonstrates, the UIMenuItem.Action property is used to associate the UIMenuItem with a method decorated with the ExportAttribute attribute.

C# Example

void ShowResetMenu (UILongPressGestureRecognizer gestureRecognizer)
  if (gestureRecognizer.State == UIGestureRecognizerState.Began) {
	    var menuController = UIMenuController.SharedMenuController;
	    var resetMenuItem = new UIMenuItem ("Reset", new Selector ("ResetImage"));
	    var location = gestureRecognizer.LocationInView (gestureRecognizer.View);
	    BecomeFirstResponder ();
	    menuController.MenuItems = new [] { resetMenuItem };
	    menuController.SetTargetRect (new RectangleF (location.X, location.Y, 0, 0), gestureRecognizer.View);
	    menuController.MenuVisible = true;
	    imageForReset = gestureRecognizer.View;
void ResetImage (UIMenuController controller)
  var mid = new PointF ((imageForReset.Bounds.Left + imageForReset.Bounds.Right) / 2, (imageForReset.Bounds.Top + imageForReset.Bounds.Bottom) / 2);
  var locationInSuperview = imageForReset.ConvertPointToView (mid, imageForReset.Superview);
  imageForReset.Layer.AnchorPoint = new PointF (0.5f, 0.5f);
  imageForReset.Center =locationInSuperview;

  UIView.BeginAnimations (null, IntPtr.Zero);
  imageForReset.Transform = MonoTouch.CoreGraphics.CGAffineTransform.MakeIdentity ();
  UIView.CommitAnimations ();

Related content


Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions:

The members of MonoTouch.UIKit.UIMenuItem are listed below.

See Also: NSObject

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

ActionSelector. The action associated with this UIMenuItem.
ClassHandleIntPtr. The handle for this class.
TitleString. The title of this UIMenuItem.