diff --git a/src/Controls/src/Core/Compatibility/Handlers/iOS/FrameRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/iOS/FrameRenderer.cs index 4143bf32ff74..e6546fa1ada6 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/iOS/FrameRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/iOS/FrameRenderer.cs @@ -173,6 +173,12 @@ protected override void Dispose(bool disposing) } } + public override void SetNeedsLayout() + { + base.SetNeedsLayout(); + Superview?.SetNeedsLayout(); + } + [Microsoft.Maui.Controls.Internals.Preserve(Conditional = true)] class FrameView : Microsoft.Maui.Platform.ContentView { diff --git a/src/Core/src/Platform/iOS/ContentView.cs b/src/Core/src/Platform/iOS/ContentView.cs index 703497815488..8e867638c2d1 100644 --- a/src/Core/src/Platform/iOS/ContentView.cs +++ b/src/Core/src/Platform/iOS/ContentView.cs @@ -31,6 +31,12 @@ public override void LayoutSubviews() CrossPlatformArrange?.Invoke(bounds); } + public override void SetNeedsLayout() + { + base.SetNeedsLayout(); + Superview?.SetNeedsLayout(); + } + internal Func? CrossPlatformMeasure { get; set; } internal Func? CrossPlatformArrange { get; set; } } diff --git a/src/Core/src/Platform/iOS/LayoutView.cs b/src/Core/src/Platform/iOS/LayoutView.cs index 9e62b4ec6ec6..7b0013440f2c 100644 --- a/src/Core/src/Platform/iOS/LayoutView.cs +++ b/src/Core/src/Platform/iOS/LayoutView.cs @@ -33,11 +33,16 @@ public override void LayoutSubviews() base.LayoutSubviews(); var bounds = AdjustForSafeArea(Bounds).ToRectangle(); - CrossPlatformMeasure?.Invoke(bounds.Width, bounds.Height); CrossPlatformArrange?.Invoke(bounds); } + public override void SetNeedsLayout() + { + base.SetNeedsLayout(); + Superview?.SetNeedsLayout(); + } + public override void SubviewAdded(UIView uiview) { base.SubviewAdded(uiview); diff --git a/src/Core/src/Platform/iOS/ViewExtensions.cs b/src/Core/src/Platform/iOS/ViewExtensions.cs index 8299e1cb192c..b127581b064a 100644 --- a/src/Core/src/Platform/iOS/ViewExtensions.cs +++ b/src/Core/src/Platform/iOS/ViewExtensions.cs @@ -40,33 +40,21 @@ public static void Unfocus(this UIView platformView, IView view) public static void UpdateVisibility(this UIView platformView, Visibility visibility) { - var shouldLayout = false; - switch (visibility) { case Visibility.Visible: - shouldLayout = platformView.Inflate(); + platformView.Inflate(); platformView.Hidden = false; break; case Visibility.Hidden: - shouldLayout = platformView.Inflate(); + platformView.Inflate(); platformView.Hidden = true; break; case Visibility.Collapsed: platformView.Hidden = true; platformView.Collapse(); - shouldLayout = true; break; } - - // If the view is just switching between Visible and Hidden, then a re-layout isn't necessary. The return value - // from Inflate will tell us if the view was previously collapsed. If the view is switching to or from a collapsed - // state, then we'll have to ask for a re-layout. - - if (shouldLayout) - { - platformView.Superview?.SetNeedsLayout(); - } } public static void UpdateBackground(this ContentView platformView, IBorderStroke border)