Search code examples
iosxamarinmvvmcrosscontrollers

MvxBaseTouchViewPresenter: (ChoosePictureFromLibrary dialog does not appear)


I am using custom Presenter. I create root navigation controller:

    public MainRootPresenter(UIApplicationDelegate applicationDelegate, UIWindow window)
    {
        _rootController = new UINavigationController(); // or: new UIViewController(); (no difference)
        window.RootViewController = rootController;
    }

then in public override void Show(MvxViewModelRequest request) do all my own kitchen with views and controllers.

However, I've got a problem when trying to get image from iPhone images library via _pictureChooserTask.ChoosePictureFromLibrary( On this method call nothing happens. There are not any exceptions.

I guess, the problem is that the standard dialog (from sdk) has some problems with that (or the presenter has - not sure. I've tried not to use the presenter and it works fine with my view (the code is pretty straight forward actually - I do nothing special). So, seems the SDK (with the library image picker controller) adds it to not expected by the presenter location or something.

I've even tried the simpliest approach with the Presenter (to be sure that's not my custom logic with other controllers):

    public override void Show(MvxViewModelRequest request)
    {
        var controller0 = (UIViewController)Mvx.Resolve<IMvxTouchViewCreator>().CreateView(request);
        _rootController.PushViewController(controller0, false);
    }

and nothing still happens.

How is that possible to manage? Thanks!


Solution

  • The imagepicker uses the PresentModalViewController method within the Presenter

    You haven't included that method in your question.

    Regardless, take a look at the standard presenters like MvxTouchViewPresenter.cs to see what they do. You might be able to adapt it for your custom circumstances.

        public override bool PresentModalViewController(UIViewController viewController, bool animated)
        {
            CurrentTopViewController.PresentViewController(viewController, animated, () => { });
            return true;
        }