有在MonoTouch.Dialog每个rootElement的一个专用的UIViewController? [英] Have a dedicated UIViewController for each RootElement in MonoTouch.Dialog?
问题描述
这很容易在 MonoTouch.Dialog
以创建使用嵌套的 RootElements
A多级菜单结构,但你会怎样去具有特定的UIViewController
管理每一根呢?我想之所以每个 rootElement的
有它自己的的UIViewController
,是因为我希望能够轻松控制之类的背景图像和屏幕间切换的导航栏和这样做是从的UIViewController
。
It's easy to create a multi-level menu structure using nested RootElements
in MonoTouch.Dialog
but how would you go about having a specific UIViewController
manage each root instead? The reason I want each RootElement
to have it's own UIViewController
is because I want to be able to easily control things like background image and toggling the NavigationBar from screen to screen and doing so is trival from within a UIViewController
.
推荐答案
我认为你正在寻找这样的:
I think you're looking for this:
public RootElement (string caption, Func<RootElement, UIViewController> createOnSelected)
这让你创建的UIViewController
(如 DialogViewController
您自定义或从它继承一个类型)。
which let you create the UIViewController
(e.g. a DialogViewController
that you customized or a type that inherit from it).
这会让你保持筑巢你的元素
同时也让大多数在视图控件和它的控制器。
This will let you keep nesting your Element
while giving most of the control over the view and it's controller.
更新
下面是如何可以用:
首先声明你的方法将创建的UIViewController。该方法的签名必须匹配 Func键< rootElement的,UIViewController的>
,如:
First declare your method that will create the UIViewController. The method signature must match Func<RootElement, UIViewController>
, e.g.
static UIViewController CreateFromRoot (RootElement element)
{
return new DialogViewController (element);
}
接下来创建一个使用你的根元素:
Next create your root elements using:
var root_element = new RootElement ("caption", CreateFromRoot);
上面会给你一样的:
var root_element = new RootElement ("caption");
除非你现在能够自定义 DialogViewController
根据自己的喜好返回之前。
except you're now able to customize the DialogViewController
to your liking before returning it.
这篇关于有在MonoTouch.Dialog每个rootElement的一个专用的UIViewController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!