添加Monotouch.对话框到标准视图



我有一个标准视图,顶部有一个导航栏。我也有Monotouch。对话框设置在它自己的源文件中。我已经四处寻找解决方案,但似乎找不到一个明确的答案,如何将MTD添加到正常视图。

是否有简单的方法来做到这一点?

你实例化了DialogViewController并将它的View添加到你的 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);

在这种情况下,你可能会遇到ViewController方法(即旋转方法)没有被正确转发的问题,所以一定要测试。

这是非常丑陋的,应该只在你绝对必须嵌套Dialog视图时使用。

在全屏显示DialogViewController(带或不带导航栏)的场景中,更优雅的解决方案是使用UINavigationController作为应用程序中的根视图控制器(它将为您照顾导航栏),并设置或推送新创建的DialogViewController到它上面。

最新更新