redth-org / BTProgressHUD

Port to Xamarin.iOS of the SVProgressHUD
Other
118 stars 64 forks source link

When BTProgressHUD is used togheter with CRSAlertView, it stops showing #52

Closed vackup closed 7 years ago

vackup commented 8 years ago

Hi! I've found an issue. When you use BTProgressHUD togheter with CRSAlertView, it stops showing.

The issue is in ProgressHUD.cs, method void ShowProgressWorker (float progress = -1, string status = null, MaskType maskType = MaskType.None, bool textOnly = false, ToastPosition toastPosition = ToastPosition.Center, string cancelCaption = null, Action cancelCallback = null, double timeoutMs = 1000, bool showContinuousProgress = false, UIImage displayContinuousImage = null)

In this code

            foreach (UIWindow window in windows) {
                    if (window.WindowLevel == UIWindowLevel.Normal && !window.Hidden) {
                        window.AddSubview (OverlayView);
                        break;
                    }
                }

The issue is because CRSAlertView adds a new window, so in addttion to window.WindowLevel == UIWindowLevel.Normal && !window.Hidden, we must check is is IsKeyWindow, eg: I replaced that code with this:

var window = windows.FirstOrDefault(w => w.WindowLevel == UIWindowLevel.Normal && !w.Hidden && w.IsKeyWindow);
                if (window == null)
                {
                    throw new Exception("Can't find a visible key window to add the subview");
                }

                window.AddSubview(OverlayView);
vackup commented 8 years ago

I've created a pull request https://github.com/nicwise/BTProgressHUD/pull/51

Redth commented 7 years ago

PR #51 was merged.