Question

How is it possible to map the initWithRootViewController objective-c method in Monotouch?

From Miguel de Icaza Rosetta site, I've found the following translation but I don't know how to apply it:

Selector: initWithRootViewController:
Method: IntPtr Constructor (UIViewController rootViewController);

Then, I also have another problem to solve. I would change the UINavigationController RootViewController during runtime. Is it possible? Surfing the Web, I've found this Changing a UINavigationController’s Root View Controller. Is there a more simple solution?

Thank you in advance.

Edit: my goal is to map the initWithRootViewController method (provided in the link) in Monotouch.

Was it helpful?

Solution

To answer your first question - you simply create a new UINavigationController as below:

UINavigationController navController = new UINavigationController(rootViewController);

Technically it would be possible to change the root controller by modifying the ViewControllers property. For example:

navController.ViewControllers = new UIViewController[2] { newRootController, childController }

EDIT

Try adding the following constructor to your custom UINavigationController:

public CustomNavController(UIViewController rootViewController)
{
    ViewControllers = new UIViewController[1] { rootViewController };
}

I'm not sure if this is the best way to get it done, but it'll work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top