From: Shane Neuville Date: Wed, 1 May 2019 16:12:41 +0000 (-0600) Subject: retain local variable of page so not collected (#6054) X-Git-Tag: accepted/tizen/5.5/unified/20200421.150457~402^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dbbc5d541393fa428f3a584c02816b21159ec413;p=platform%2Fcore%2Fcsapi%2Fxsf.git retain local variable of page so not collected (#6054) --- diff --git a/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs index abaf0c4..b58677d 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs @@ -16,6 +16,8 @@ namespace Xamarin.Forms.Platform.iOS VisualElementPackager _packager; VisualElementTracker _tracker; + // storing this into a local variable causes it to not get collected. Do not delete this please + PageContainer _pageContainer; internal PageContainer Container => NativeView as PageContainer; Page Page => Element as Page; @@ -121,9 +123,11 @@ namespace Xamarin.Forms.Platform.iOS public override void LoadView() { - View = new PageContainer(this); - } + if (_pageContainer == null) + _pageContainer = new PageContainer(this); + View = _pageContainer; + } public override void ViewWillLayoutSubviews() { base.ViewWillLayoutSubviews(); @@ -262,6 +266,7 @@ namespace Xamarin.Forms.Platform.iOS Element = null; Container?.Dispose(); + _pageContainer = null; _disposed = true; }