- sender
- Object calling this method.
Applications overriding this method should expose the selected information and pass it to the UIKit.UIPasteboard.
You can invoke the Copy method to retrieve the contents of the object and have them on the pasteboard, for example:
c# Example
void MakeCopy (UITextField field) { field.Copy (this); }
The following example shows how to implement the Copy method on your own subclass of UIResponder.
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; } }