Skip to content

Commit

Permalink
Once a keyboard has been opened and dismissed, the HUD will always be…
Browse files Browse the repository at this point in the history
… offset by the keyboard height. We don't want that. So now we check if the keyboard's frame is on screen.
  • Loading branch information
matt4pi committed Nov 22, 2018
1 parent e6a7631 commit 99f3361
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions BTProgressHUD/ProgressHUD.cs
Expand Up @@ -130,7 +130,7 @@ public void Show (string status = null, float progress = -1, MaskType maskType =
}

public void Show (string cancelCaption, Action cancelCallback, string status = null,
float progress = -1, MaskType maskType = MaskType.None, double timeoutMs = 1000)
float progress = -1, MaskType maskType = MaskType.None, double timeoutMs = 1000)
{
// Making cancelCaption optional hides the method via the overload
if (string.IsNullOrEmpty (cancelCaption)) {
Expand Down Expand Up @@ -263,8 +263,8 @@ public override void Draw (CGRect rect)
}

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)
ToastPosition toastPosition = ToastPosition.Center, string cancelCaption = null, Action cancelCallback = null,
double timeoutMs = 1000, bool showContinuousProgress = false, UIImage displayContinuousImage = null)
{

Ring.ResetStyle(IsiOS7ForLookAndFeel, (IsiOS7ForLookAndFeel ? TintColor : UIColor.White));
Expand All @@ -274,7 +274,7 @@ public override void Draw (CGRect rect)
var windows = UIApplication.SharedApplication.Windows;
Array.Reverse (windows);
foreach (UIWindow window in windows) {
if (window.WindowLevel == UIWindowLevel.Normal && !window.Hidden && window.IsKeyWindow) {
if (window.WindowLevel == UIWindowLevel.Normal && !window.Hidden && window.IsKeyWindow) {
window.AddSubview (OverlayView);
break;
}
Expand Down Expand Up @@ -672,13 +672,17 @@ CAShapeLayer CreateRingLayer (CGPoint center, float radius, float lineWidth, UIC
foreach (var possibleKeyboard in testWindow.Subviews) {
if ((clsUIPeripheralHostView != null && possibleKeyboard.IsKindOfClass(clsUIPeripheralHostView)) ||
(clsUIKeyboard != null && possibleKeyboard.IsKindOfClass(clsUIKeyboard))) {
return (float)possibleKeyboard.Bounds.Size.Height;
// Check that the keyboard is actually on screen
if (possibleKeyboard.Frame.IntersectsWith(testWindow.Frame))
return (float)possibleKeyboard.Bounds.Size.Height;
}
else if (clsUIInputSetContainerView != null && possibleKeyboard.IsKindOfClass(clsUIInputSetContainerView)) {
foreach (var possibleKeyboardSubview in possibleKeyboard.Subviews)
{
if (clsUIInputSetHostView != null && possibleKeyboardSubview.IsKindOfClass(clsUIInputSetHostView))
return (float)possibleKeyboardSubview.Bounds.Size.Height;
// Check that the keyboard is actually on screen
if (possibleKeyboardSubview.Frame.IntersectsWith(testWindow.Frame))
return (float)possibleKeyboardSubview.Bounds.Size.Height;
}
}
}
Expand Down Expand Up @@ -933,8 +937,8 @@ void UpdatePosition (bool textOnly = false)

if (IsIOS7OrNewer) {
var stringSize = new NSString (@string).GetBoundingRect (new CGSize (200, 30 * lineCount), NSStringDrawingOptions.UsesLineFragmentOrigin,
new UIStringAttributes{ Font = StringLabel.Font },
null);
new UIStringAttributes{ Font = StringLabel.Font },
null);
stringWidth = stringSize.Width;
stringHeight = stringSize.Height;
} else {
Expand All @@ -944,7 +948,7 @@ void UpdatePosition (bool textOnly = false)
}



hudHeight += stringHeight;

Expand All @@ -970,8 +974,8 @@ void UpdatePosition (bool textOnly = false)

if (IsIOS7OrNewer) {
var stringSize = new NSString (@cancelCaption).GetBoundingRect (new CGSize (200, 300), NSStringDrawingOptions.UsesLineFragmentOrigin,
new UIStringAttributes{ Font = StringLabel.Font },
null);
new UIStringAttributes{ Font = StringLabel.Font },
null);
stringWidth = stringSize.Width;
stringHeight = stringSize.Height;
} else {
Expand Down

0 comments on commit 99f3361

Please sign in to comment.