private protected override void OnLoaded() { base.OnLoaded(); // TODO: Find a proper way to decide whether a CommandBar exists on canvas (within Page), or is mapped to the UINavigationController's NavigationBar. CommandBar?commandBar = null; _commandBar?.TryGetTarget(out commandBar); if (_commandBar == null) { commandBar = TemplatedParent as CommandBar; _commandBar = new WeakReference <CommandBar?>(commandBar); _navigationBar = commandBar?.GetRenderer(RendererFactory).Native; } else { _navigationBar = commandBar?.ResetRenderer(RendererFactory).Native; } if (_navigationBar == null) { throw new InvalidOperationException("No NavigationBar from renderer"); } _navigationBar.SetNeedsLayout(); var navigationBarSuperview = _navigationBar?.Superview; // Allows the UINavigationController's NavigationBar instance to be moved to the Page. This feature // is used in the context of the sample application to test NavigationBars outside of a NativeFramePresenter for // UI Testing. In general cases, this should not happen as the bar may be moved back to to this presenter while // another page is already visible, making this bar overlay on top of another. if (FeatureConfiguration.CommandBar.AllowNativePresenterContent && (navigationBarSuperview == null || navigationBarSuperview is NativeCommandBarPresenter)) { Content = _navigationBar; } var statusBar = StatusBar.GetForCurrentView(); statusBar.Showing += OnStatusBarChanged; statusBar.Hiding += OnStatusBarChanged; _statusBarSubscription.Disposable = Disposable.Create(() => { statusBar.Showing -= OnStatusBarChanged; statusBar.Hiding -= OnStatusBarChanged; }); // iOS doesn't automatically update the navigation bar position when the status bar visibility changes. void OnStatusBarChanged(StatusBar sender, object args) { _navigationBar !.SetNeedsLayout(); _navigationBar !.Superview.SetNeedsLayout(); } }