stormlion227 / ImageCropper.Forms

Xamarin.Forms plugin to crop and rotate photos.
MIT License
87 stars 59 forks source link

Cropper page doesn't show on Modal page iOS. #22

Open 3esam opened 5 years ago

3esam commented 5 years ago

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:

https://github.com/stormlion227/ImageCropper.Forms/blob/b2af168d658c2ae3394cabe2b465c4b473170448/ImageCropper/ImageCropper.iOS/ImageCropperImplementation.cs#L54

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);
simonemarra commented 4 years ago

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!

Confusedfish commented 3 years ago

Thanks for the tip, this helped me immensely