diff options
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs b/Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs index 4d1252ee..cde9fe81 100644 --- a/Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs @@ -1,8 +1,13 @@ using CoreGraphics; -using UIKit; using Xamarin.Forms.Internals; - +#if __MOBILE__ +using UIKit; namespace Xamarin.Forms.Platform.iOS +#else +using UIView = AppKit.NSView; + +namespace Xamarin.Forms.Platform.MacOS +#endif { public class NativeViewWrapperRenderer : ViewRenderer<NativeViewWrapper, UIView> { @@ -19,6 +24,7 @@ namespace Xamarin.Forms.Platform.iOS return result ?? base.GetDesiredSize(widthConstraint, heightConstraint); } +#if __MOBILE__ public override void LayoutSubviews() { if (Element?.LayoutSubViews == null) @@ -50,6 +56,26 @@ namespace Xamarin.Forms.Platform.iOS // if it returns null, fall back to the default implementation return result ?? base.SizeThatFits(size); } +#else + public override void Layout() + { + if (Element?.LayoutSubViews == null) + { + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + base.Layout(); + return; + } + + // The user has specified a different implementation of LayoutSubviews + var handled = Element.LayoutSubViews(); + + if (!handled) + { + // If the delegate wasn't able to handle the request, fall back to the default implementation + base.Layout(); + } + } +#endif protected override void OnElementChanged(ElementChangedEventArgs<NativeViewWrapper> e) { |