I created a Shell app utilizing Tabs for iOS. Two of the Tabs (Tab1 & Tab2) create pages (Page1 & Page2) that devour loads of reminiscence every. If I click on Tab1 after which Tab2 the app crashes resulting from an excessive amount of reminiscence utilization as a result of Page1 stays alive as Page2 is created. The identical is true if I click on Tab2 then Tab1. The reminiscence utilization of Page1 or Page2 is suitable when solely one in every of them is instantiated however the two collectively causes iOS to evict my app.
The primary time I click on on Tab1, Page1 is instantiated. If Page1 is being displayed and I navigate to the Page2, how can I eliminate Page1 and have it recreated once I click on Tab1? I am very keen to dwell with the additional time required to reinstantiate both Page1 or Page2 every time their respective Tabs are clicked.
I attempted utilizing:
protected override void OnDisappearing()
{
Shell.Present.Navigation.RemovePage(Shell.Present.Navigation.NavigationStack.ElementAt(0));
}
to take away the primary web page on the NavigationStack as I navigate away from Page1 however this throws a System.ArgumentNullException. The Navigation Stack does have 1 aspect however that aspect is Null. It is not Page1.
Each time I navigate away from Page1, I need the subsequent click on on Tab1 to be handled as if it was the primary click on. Similar with Tab2 & Page2. Any assist can be significantly appreciated!