stormlion227 / ImageCropper.Forms

Xamarin.Forms plugin to crop and rotate photos.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cropper page doesn't show on Modal page iOS.

3esam opened this issue · comments

commented

I've encountered this issue before where presenting a ViewController from native iOS in a xamarin.forms app... if the current page is pushed modally then the ViewController wont show up.

The fix is in this line:

UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(cropViewController, true, null);

please use this bit of code instead:

        UIWindow window = UIApplication.SharedApplication.KeyWindow;
        UIViewController viewController = window.RootViewController;

        while (viewController.PresentedViewController != null)
        {
            viewController = viewController.PresentedViewController;
        }
        viewController.PresentViewController(cropViewController, true, null);

Hi,
I'm having the same issue since I had to change the page launching the imagecropper component, using now a Modal page instead a standard navigation page.
I'll try your patch, thank you!

Thanks for the tip, this helped me immensely