Using an iOS storyboard and viewcontroller in Maui

Phunction 256 Reputation points
2024-09-08T05:12:48.15+00:00

I am in the process of porting my xamarin.ios project to maui.

Unfortuanately I have a storyboard and viewcontroller I cannot replicate in maui. (Dropbox)

Is there a way I can use that part in my maui project?

I copied the files to Platforms/iOS but not sure how to actually launch them from a button on the maui side.

It consists of a storyboard file and amd associated UIViewController

I tried this, but I get an exception "Could not find a storyboard named Dropbox in bundle NSBundle"

UIStoryboard board = UIStoryboard.FromName("Dropbox", null); << EXCEPTION HERE

UIViewController ctrl = (UIViewController)board.InstantiateViewController("CDropBoxVC"); 

// Get the current Navigation Controller
var windowScene = UIApplication.SharedApplication .ConnectedScenes
.ToArray()
.FirstOrDefault(s => s.ActivationState == UISceneActivationState.ForegroundActive) as UIWindowScene;

if (windowScene != null)
{
    var window = windowScene.Windows.FirstOrDefault();
    if (window != null)
    {
        var navigationController = window.RootViewController as UINavigationController;
        if (navigationController != null)
        {
            navigationController.PushViewController(ctrl, true);
        }
        else
        {
            window.RootViewController.PresentViewController(ctrl, true, null);
        }
    }
}

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,346 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,453 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Phunction 256 Reputation points
    2024-09-08T18:27:57.63+00:00

    Realized my storyboard was missing the title= tag.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.