- action
- The selector that represents the action that is being probed. For editing operations, these selectors are "copy:", "cut:", "delete:", "paste:", "select:", "selectAll:", "toggleBoldface:", "toggleItalics:", "toggleUnderline:".
- withSender
The object invoking this method.
This parameter can be null.
True if the specified action can be performed with the specified sender.
This method should return true if the action specified by the selector can be performed by the object.
c# Example
// // Selectable label: a label that shows the "Copy" menu when the user // long presses // public class SelectableLabel : UILabel { public SelectableLabel (RectangleF rect) : base (rect) { UserInteractionEnabled = true; var gesture = new UILongPressGestureRecognizer (LongPress); AddGestureRecognizer (gesture); } void LongPress (UILongPressGestureRecognizer r) { var location = r.LocationInView (r.View); var menu = UIMenuController.SharedMenuController; r.View.BecomeFirstResponder (); menu.SetTargetRect (r.View.Frame, r.View); menu.SetMenuVisible (true, true); } public override bool CanBecomeFirstResponder { get { return true; } } Selector copyAction = new Selector ("copy"); public override bool CanPerform (Selector action, NSObject withSender) { if (action == copyAction); return true; return false; } public override void Copy (NSObject sender) { UIPasteboard.General.String = this.Text; } }