UIMenuItem Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates menu items that are attached to the editing menu.
[Foundation.Register("UIMenuItem", true)]
public class UIMenuItem : Foundation.NSObject
[<Foundation.Register("UIMenuItem", true)>]
type UIMenuItem = class
inherit NSObject
- Inheritance
- Attributes
Remarks
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 MenuItems property.
As the following code, taken from the "Touches_GestureRecognizer" sample demonstrates, the Action property is used to associate the UIMenuItem with a method decorated with the ExportAttribute attribute.
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 CGRect (location.X, location.Y, 0, 0), gestureRecognizer.View);
menuController.MenuVisible = true;
imageForReset = gestureRecognizer.View;
}
}
[Export("ResetImage")]
void ResetImage (UIMenuController controller)
{
var mid = new CGPoint ((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 CGPoint (0.5f, 0.5f);
imageForReset.Center =locationInSuperview;
UIView.BeginAnimations (null, IntPtr.Zero);
imageForReset.Transform = MonoTouch.CoreGraphics.CGAffineTransform.MakeIdentity ();
UIView.CommitAnimations ();
}
Constructors
| Name | Description |
|---|---|
| UIMenuItem() |
Creates a new UIMenuItem with default values. |
| UIMenuItem(NativeHandle) |
A constructor used when creating managed representations of unmanaged objects. Called by the runtime. |
| UIMenuItem(NSObjectFlag) |
Constructor to call on derived classes to skip initialization and merely allocate the object. |
| UIMenuItem(String, Selector) | |
Properties
| Name | Description |
|---|---|
| AccessibilityAttributedUserInputLabels | (Inherited from NSObject) |
| AccessibilityRespondsToUserInteraction | (Inherited from NSObject) |
| AccessibilityTextualContext | (Inherited from NSObject) |
| AccessibilityUserInputLabels | (Inherited from NSObject) |
| Action | |
| Class | (Inherited from NSObject) |
| ClassHandle |
The Objective-C class handle for this class. |
| DebugDescription | (Inherited from NSObject) |
| Description | (Inherited from NSObject) |
| Handle |
Handle (pointer) to the unmanaged object representation. (Inherited from NSObject) |
| IsDirectBinding | (Inherited from NSObject) |
| IsProxy | (Inherited from NSObject) |
| RetainCount | (Inherited from NSObject) |
| Self | (Inherited from NSObject) |
| Superclass | (Inherited from NSObject) |
| SuperHandle |
Handle used to represent the methods in the base class for this NSObject. (Inherited from NSObject) |
| Title | |
| Zone | (Inherited from NSObject) |