Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Open Root Viewcontroller from App.cs of Shared Project

vkt_rbvkt_rb USMember ✭✭✭

Hi everyone, I'm in a struggle, I'm working in multiplataform shared project right now, and I'm developing the iOS part, I'm very new in iOS, my problem right now is that I have a kind of login logic in my App.cs file in my shared core, and in there I determine which page going to be the MainPage in Android, and I need to do the same for iOS but I don't know how to open my ViewController from it. The following is the code that I had:

private void configurarInicioApp()
        {
            try
            {
                LogicaBaseLocal logica = new LogicaBaseLocal();
                int Resultado = 0;
                Resultado = logica.ConsultarID();

                switch (Resultado)
                {

                    case -1:

                        #if __ANDROID__
                        MainPage = new NavigationPage(new Frm_Registro());
                        #endif

                        #if __IOS__
                            //In here I need to set my rootPage from one of the viewController in the iOS project
                        #endif

                        break;
                    case 0:
                        #if __ANDROID__
                        MainPage = new NavigationPage(new Frm_Principal());
                        #endif
                        break;
                    case 1:

                        #if __ANDROID__
                        MainPage = new NavigationPage(new Frm_Principal());
                        #endif
                        break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

I'm not pretty sure if that is possible, but I would like to use this shared logic for al the plataforms in my code to not write it in all of them. Thanks for the help.

Sign In or Register to comment.