Open johnnysbug opened 9 years ago
I have had success in another renderer, but only because the content view controller was pulled from a Storyboard, like so:
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
var hostViewController = ViewController;
var storyboard = UIStoryboard.FromName("Main_iPhone", null);
var viewController = storyboard.InstantiateViewController("MyTabBarController") as MyTabBarController;
Sidebar = new SidebarController(this, viewController, new MenuViewController());
hostViewController.AddChildViewController(viewController);
hostViewController.View.Add(viewController.View);
viewController.DidMoveToParentViewController(hostViewController);
}
The above does work and I can see menu content. However, in my other renderer, the content view is an actual XF Page.
In my app I got the same behaviour with the following code:
var formsPage = (Page)this.Element;
//var navigationController = new UINavigationController { NavigationBarHidden = true };
//navigationController.PushViewController(formsPage.CreateViewController(), false);
var sidebarController = new SidebarNavigation.SidebarController(
formsPage.CreateViewController(), this, new SideMenuController());
I have a working example using Xamarin Forms here: https://github.com/jdehlin/Xamarin-Sidebar/tree/master/XamarinFormsSample
Have you taken a look at that?
Yes, but the difference is that in your samples you are new-ing a ContentController or a page and then create a view controller. In my code I am using an existing formsPage and then call the CreateViewController in the renderer.
Here's how I am setting up the SideBarController for one of my Xamarin Forms pages (via a renderer):
My Renderer:
When I slide the menu out, it is a blank white view. I've tried other options, like just newing up a view controller and passing that in as the root view controller, but I see the same results. I've tried moving this code to the OnElementChanged method, but still the same problem.
Have you or anyone else had any success when integrating with Xamarin Forms?