UIKit.UIMenuItem Class
Creates menu items that are attached to the editing menu.

See Also: UIMenuItem Members

Syntax

[Foundation.Register("UIMenuItem", true)]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.iOS_3_2)]
public class UIMenuItem : Foundation.NSObject

Remarks

UIKit.UIMenuItems are menu items that appear on the editing menu after the system menu items. UIKit.UIMenuItems are managed by a UIKit.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 UIKit.UIMenuItem with a method decorated with the Foundation.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;
	  }
}
[Export("ResetImage")]
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 = CoreGraphics.CGAffineTransform.MakeIdentity ();
  UIView.CommitAnimations ();
}          

Related content

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0