答案 0 :(得分:0)
" UIMenuController"与" menuItems:"将对您的自定义操作有用。
Apple文档链接:https://developer.apple.com/reference/uikit/uimenucontroller
答案 1 :(得分:0)
感谢Ios开发人员的指导..我已经使用了" UIMenuController",但此菜单未显示。
我的代码:
[Export("LongPressMethod:")]
public void LongPressMethod(UILongPressGestureRecognizer gestureRecognizer)
{
if (gestureRecognizer.State == UIGestureRecognizerState.Began)
{
var menuController = UIMenuController.SharedMenuController;
var copyMenuItem = new UIMenuItem("copy", new ObjCRuntime.Selector("CopyRow"));
var pasteMenuItem = new UIMenuItem("paste", new ObjCRuntime.Selector("PasteRow"));
var location = gestureRecognizer.LocationInView(bc);
bc.BecomeFirstResponder();
menuController.MenuItems = new[] { copyMenuItem, pasteMenuItem };
menuController.SetTargetRect(new CGRect(location.X, location.Y, 100, 100), bc);
menuController.SetMenuVisible(true, true);
}
}
[Export("CopyRow:")]
void Row(UIMenuController controller)
{
// do something
}
[Export("PasteRow:")]
void PasteRow(UIMenuController controller)
{
// do something
}