How can remove 'share' and 'look up' menu items from UIMenuController in IOS

gdkgdk INMember ✭✭✭

Hi everyone, I have to search for hiding the system default menu items from UIMenuController but I am not able to find any way to satisfy my requirements. Please suggest any idea. Thanks in advance. What I have tried is.

 if(action.name == new selector("_lookup:"))
{
    return false;
}

Hear I can find out the required menu item and returns false. The above code is write in can perform method but still show the look up menu item in menu controller.

Answers

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @gdk

    The Look Up menu is actually action _define: and Share is _share: So try this in your subclass of UITextView (or UITextField);

    public override bool CanPerform(ObjCRuntime.Selector action, NSObject withSender)
    {
          if (action.Name == "_define:" || action.Name == "_share:")
               return false;
    
          return base.CanPerform(action, withSender);
    }
    
  • gdkgdk INMember ✭✭✭

    Hi jon, I have tried what you are saying but con't get the result, Still it showing lookup and share menu items in menu controller.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @gdk

    Attached is a very simple sample that works on my end to remove those edit menu entries, Look Up... and Share...

  • luoluoluoluo Member

    @JGoldberger 看了你的评论 解决了我的问题 谢谢你!

Sign In or Register to comment.