我不知道为什么我的 UIMenuController 没有出现在我的视图中。当我长按按钮时,我可以看到所有指令都已执行,但没有显示菜单。
public class MySingleArticleView : UIView
{
private MyArticleViewController _controller; // MyArticleViewController extends BaseViewController
public MySingleArticleView (MyArticleViewController controller, ...)
{
_controller = controller;
// ... init code
}
void ArticleLongPressed (UILongPressGestureRecognizer gestureRecognizer)
{
var menuController = UIMenuController.SharedMenuController;
var copyMenuItem = new UIMenuItem ("copy", new Selector ("CopyRow"));
var pasteMenuItem = new UIMenuItem ("paste", new Selector ("PasteRow"));
var location = gestureRecognizer.LocationInView (_controller.View);
_controller.BecomeFirstResponder ();
menuController.MenuItems = new [] { copyMenuItem, pasteMenuItem };
menuController.SetTargetRect (new CGRect (location.X, location.Y, 0, 0), _controller.View);
menuController.SetMenuVisible (true, true);
}
[Export("CopyRow")]
void Row (UIMenuController controller)
{
// do something
}
[Export("PasteRow")]
void PasteRow (UIMenuController controller)
{
// do something
}
}
我忘记了什么?