protected override void OnElementChanged(ElementChangedEventArgs <PageViewContainer> e) { base.OnElementChanged(e); var pageViewContainer = e.NewElement as PageViewContainer; if (_viewControllerContainer != null) { _viewControllerContainer.ViewController = null; _viewControllerContainer = null; } if (e.NewElement != null) { _viewControllerContainer = new ViewControllerContainer(Bounds); SetNativeControl(_viewControllerContainer); } }
void ChangePage(Page page) { if (_currentPage == page) { return; } //TODO call page dissapaering/appearing methods if (page != null) { var pageRenderer = page.GetRenderer(); UIViewController viewController = null; if (pageRenderer?.ViewController != null) { viewController = pageRenderer.ViewController; } else { viewController = page.CreateViewController(); } var parentPage = Element.GetParentPage(); var renderer = parentPage.GetRenderer(); if (_viewControllerContainer == null) { _viewControllerContainer = new ViewControllerContainer(Bounds); SetNativeControl(_viewControllerContainer); } _viewControllerContainer.ParentViewController = renderer.ViewController; _viewControllerContainer.ViewController = viewController; _currentPage = page; FixPageLayouts(); SetNeedsLayout(); } else { _viewControllerContainer = null; } }