SharedMenuController doesn' work on native UIViewController

Jean-LouisPORCILEJean-LouisPORCILE LUMember ✭✭
edited August 2015 in Xamarin.Forms

Hi,

I'have created a binding project with objective-c library which is a PDF reader.

First I tried to use it in a Xamarin.iOS project, it worked perfectly !

Then I created a Xamarin.Forms project and call the library through a custom renderer which display a button.
When the button is touched, I call the library to instance the UIViewController like this :

`var viewController = new ReaderViewController (document);

        viewController.Delegate = selector;

        viewController.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;

        viewController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;

        this.PresentViewController(viewController,true,null);` 

It works also perfectly !

Finally I would open my reader directly when I call the Renderer. I did it like this by overriding the OnElementChanged event :

`var viewController = new ReaderViewController (document);

        selector = new ViewerDelegate (this);
        viewController.Delegate = selector;

        viewController.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;

        viewController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;

        var menu = UIMenuController.SharedMenuController;

        hostViewController.AddChildViewController (viewController);
        hostViewController.View.Add (viewController.View);

        viewController.DidMoveToParentViewController (hostViewController);`

Here is the issue, the reader is opened properly but UIMenu which is normally displayed when a longpresse gesture is applied on the reader does no longer works.

I have tried to debug the library to find out where is the problem. The longpresse event is correctly handled and the sharedMenuController.menuItems contains the 2 MenuItem.

I try to check the "CanBecomeFirstResponder" Method and actually it seems to be "false"

And the "CanPerformAction" is never executed.

Can you help me please ?

Posts

Sign In or Register to comment.