My Xamarin iOS app is crashing on a ContentPage when I switch away from it to another app.
The first occurrence was in a label renderer, so I wrapped it in a try catch block:
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
//Add a try because of this:
//https://stackoverflow.com/questions/46881393/ios-crash-report-unexpected-start-state-exception
try
{
base.OnElementChanged(e);
if (label != null)
{
sv = label.Parent as ScrollViewEx;
}
}
catch
{
}
}
Now it is crashing in another part of the app trying to access a disposed editor object when I switch away.
Is there a life cycle thing going on here that I need to be aware of in terms of why the OS is trying to re-render UI objects in such circumstances?
And how can I generically protect my app from these sorts of crashes without having to wrap every single UI object in a try catch just because I'm switching to another app?