title: Object reference crash in ViewWillAppear in PageRenderer xamarin forms ios
body: <p>We customize the toolbar menu for navigation back button in xamarin forms ios. I am getting below crash in appcenter.
  ToolbarMenuCustomRenderer.ViewWillAppear (System.Boolean animated)
  SIGABRT: Object reference not set to an instance of an object</p>
  <p>Code snippet below:</p>
  <pre><code>public override void ViewWillAppear(bool animated)
          {
              base.ViewWillAppear(animated);
  
              CustomToolbarContentPage page = Element as CustomToolbarContentPage;
              if (page == null)
                  return;
  
              #region for soft back button
  
              UIViewController root = NavigationController.TopViewController;
              if (!page.NeedOverrideSoftBackButton)
                  return;
  
              string title = &quot;&lt;&quot; + (string.IsNullOrEmpty(NavigationPage.GetBackButtonTitle(Element)) ? &quot;&quot; : NavigationPage.GetBackButtonTitle(Element));
  
              root.NavigationItem.SetLeftBarButtonItem(
                  new UIBarButtonItem(title, UIBarButtonItemStyle.Plain, (sender, args) =&gt;
                  {
                      page.OnSoftBackButtonPressed();
                  }), true);
  
              #endregion
          }
  </code></pre>
  <p>How to resolve this in xamarin forms ios?</p>