UIMenuController 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.
The class used to implement Cut, Copy, Paste, Select, and Delete commands.
[Foundation.Register("UIMenuController", true)]
public class UIMenuController : Foundation.NSObject
[<Foundation.Register("UIMenuController", true)>]
type UIMenuController = class
inherit NSObject
- Inheritance
- Attributes
Remarks
The UIMenuController is a singleton object, accessed by SharedMenuController. It manages the editng menu, which provides options for Cut, Copy, Paste, Select, Select All, and Delete commands. The menu is visually associated with a target rectangle specified by SetTargetRect(CGRect, UIView). It is the application developer's responsibility to set this target rectangle appropriately before displaying the UIMenuController.
The application can add or delete additional menu items using the MenuItems. The following code, taken from the "Touches Gesture Recognizers" sample shows the code necessary to create a modified context menu:
void Setup ()
{
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;
menuController.Animated = 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 |
|---|---|
| UIMenuController() |
Creates a new UIMenuController with default values. |
| UIMenuController(NativeHandle) |
A constructor used when creating managed representations of unmanaged objects. Called by the runtime. |
| UIMenuController(NSObjectFlag) |
Constructor to call on derived classes to skip initialization and merely allocate the object. |
Properties
| Name | Description |
|---|---|
| AccessibilityAttributedUserInputLabels | (Inherited from NSObject) |
| AccessibilityRespondsToUserInteraction | (Inherited from NSObject) |
| AccessibilityTextualContext | (Inherited from NSObject) |
| AccessibilityUserInputLabels | (Inherited from NSObject) |
| ArrowDirection | |
| Class | (Inherited from NSObject) |
| ClassHandle |
The Objective-C class handle for this class. |
| DebugDescription | (Inherited from NSObject) |
| Description | (Inherited from NSObject) |
| DidHideMenuNotification |
Notification constant for DidHideMenu |
| DidShowMenuNotification |
Notification constant for DidShowMenu |
| Handle |
Handle (pointer) to the unmanaged object representation. (Inherited from NSObject) |
| IsDirectBinding | (Inherited from NSObject) |
| IsProxy | (Inherited from NSObject) |
| MenuFrame | |
| MenuFrameDidChangeNotification |
Notification constant for MenuFrameDidChange |
| MenuItems | |
| MenuVisible | |
| RetainCount | (Inherited from NSObject) |
| Self | (Inherited from NSObject) |
| SharedMenuController | |
| Superclass | (Inherited from NSObject) |
| SuperHandle |
Handle used to represent the methods in the base class for this NSObject. (Inherited from NSObject) |
| WillHideMenuNotification |
Notification constant for WillHideMenu |
| WillShowMenuNotification |
Notification constant for WillShowMenu |
| Zone | (Inherited from NSObject) |