How to create navigation in a Xamarin.iOS app?

后端 未结 1 1111
北恋
北恋 2021-01-26 23:44

I\'m used to working with Xamarin.Forms. I create a Page in XAML or C# and navigate to it. But now it\'s my first time trying to create an iOS app that\'s not <

相关标签:
1条回答
  • 2021-01-27 00:05

    But how do I create another page and tell the app to navigate to it? Do I create another UIViewController? And if so, how do I tell one to navigate to another?

    You can create it as follow :

    Right click Xamarin IOS Project - > Add - > New Item - > User Interface (UIViewController Class / ViewController With StoryBorad )

    All I've found are tutorials that use other IDEs. How do I do it in Visual Studio not "for Mac"?

    Here is the official document about Walkthrough on Windows however about using storyboard .And there is a sample project below it.

    So if there's a different way without a storyboard, that would be better.

    If ViewController not exist in StoryBoard, then you can navigate to this Controller without StoryBoard .

    this.PresentViewController(new UIViewControllerSecond(), true, null);
    

    Else if StoryBoard contain the other ViewControllers , you also can use C# to navigate to next View.

    SecondController secondController = this.Storyboard.InstantiateViewController("SecondController ") as SecondController ;
    if (secondController != null)
    {
        this.PushViewController(secondController , true);
    }  
    

    By the way , if Setting Root View Controller as NavigationController , use this.NavigationController.PushViewController(...) to navigate.

    0 讨论(0)
提交回复
热议问题