redth-org / BTProgressHUD

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

Fixes a rare crash when Window is null #47

Closed mohibsheth closed 8 years ago

mohibsheth commented 8 years ago

After the HUD is shown and not dismissed yet, if the Window is changed for some reason, the PositionHUD still tries to get the previous Window's Bounds which is "null".

My solution was to use the KeyWindow instead. You may have a better solution to this.

nicwise commented 8 years ago

Hi @mohibsheth - sorry for the long delay. Do you have the actual diff? This is showing as a diff of the whole file.

mohibsheth commented 8 years ago

Hi @nicwise - I have made a single line change on Line 809 in ProgressHUD (https://github.com/nicwise/BTProgressHUD/blob/master/BTProgressHUD/ProgressHUD.cs#L809)

CGRect orientationFrame = UIApplication.SharedApplication.KeyWindow.Bounds;

I have made it used KeyWindow because sometimes its possible that the Window is null. Usually happens when you change the RootViewController ;)

nicwise commented 8 years ago

Merged in. Thanks!