Question

I have a standard view with a bar at the top for navigation. I also have a Monotouch.Dialog set in it's own source file. I've looked around for a solution to this, but can't seem to find a definitive answer on how to add a MTD to a normal view.

Is there a simple way to do this?

Was it helpful?

Solution

You instantiate the DialogViewController and add its View to your view.

DialogViewController vc = new DialogViewController(null);

// Build and set your root here.

vc.View.Frame = new RectangleF(20f, 20f, 280f, 560f);

this.View.AddSubview(vc.View);

You might have issues with ViewController methods (i.e. rotation methods) not being forwarded correctly in this scenario, so be sure to test.

This is extremely ugly though and should only be used when you absolutely must have the Dialog view nested.

In a scenario where the DialogViewController is displayed in full screen (with or without the navigation bar), a more elegant solution is to use a UINavigationController as the root view controller in your app (which would take care of the navigation bar for you), and either setting or pushing the newly created DialogViewController onto it.

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