Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank menu content when used with Xamarin Forms #31

Open
johnnysbug opened this issue Aug 6, 2015 · 4 comments
Open

Blank menu content when used with Xamarin Forms #31

johnnysbug opened this issue Aug 6, 2015 · 4 comments

Comments

@johnnysbug
Copy link

Here's how I am setting up the SideBarController for one of my Xamarin Forms pages (via a renderer):

My Renderer:

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var nativeView = NativeView;
            if (nativeView != null)
            {
                var rootViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
                Sidebar = new SidebarController(rootViewController, this, new MenuViewController());
            }
        }

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?

@johnnysbug
Copy link
Author

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.

@eusebiu
Copy link

eusebiu commented Jan 16, 2016

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());

@jdehlin
Copy link
Collaborator

jdehlin commented Jan 19, 2016

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?

@eusebiu
Copy link

eusebiu commented Jan 22, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants