Skip to content

Commit

Permalink
Fix null reference when window is null
Browse files Browse the repository at this point in the history
When using certain controls ie bottom sheets and search bars there can be a crash when the keyboard displays. Check for null & return early if it is.
  • Loading branch information
Axemasta committed Apr 10, 2024
1 parent 8410edb commit 5e885cd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* This class is adapted from IQKeyboardManager which is an open-source
* library implemented for iOS to handle Keyboard interactions with
* UITextFields/UITextViews. Link to their MIT License can be found here:
Expand Down Expand Up @@ -311,6 +311,11 @@ internal static void AdjustPosition()
var rootViewOrigin = new CGPoint(ContainerView.Frame.GetMinX(), ContainerView.Frame.GetMinY());
var window = ContainerView.Window;

if (window is null)
{
return;
}

var intersectRect = CGRect.Intersect(KeyboardFrame, window.Frame);
var kbSize = intersectRect == CGRect.Empty ? new CGSize(KeyboardFrame.Width, 0) : intersectRect.Size;

Expand Down

0 comments on commit 5e885cd

Please sign in to comment.