Adding a Monotouch.Dialog to a standard view

风格不统一 提交于 2019-12-12 15:04:08

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/16868553/adding-a-monotouch-dialog-to-a-standard-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!