【发布时间】:2012-05-29 15:48:51
【问题描述】:
我正在使用 Monotouch.Dialog 开发一个单位转换器,我的主窗口如下所示:
当我点击 Quantity 元素,选择一个新的 Quantity 并返回主窗口时,我想使用与所选数量相关的单位表来更新 Unit 元素。
我最初的想法是在完成数量选择后调用的事件处理程序中更新单位。但是,当我从数量选择返回时,我无法在 MT.D API 中找到触发的事件。是否有这样的事件我可以采取行动,或者是否有其他方法可以进行单元更新?
从示意图上看,我的 AppDelegate.FinishedLaunching 方法现在看起来像这样:
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
_window = new UIWindow (UIScreen.MainScreen.Bounds);
_quantityGroup = new RadioGroup("Qty", 0);
_fromUnitGroup = new RadioGroup("FromU", 0);
_toUnitGroup = new RadioGroup("ToU", 0);
var quantityElem = new RootElement("Quantity", _quantityGroup) {
new Section() { new RadioElement("AbsorbedDose", "Qty") as Element, ... }};
var fromUnitElem = new RootElement("Unit", _fromUnitGroup) { new Section() };
var toUnitElem = new RootElement("Unit", _toUnitGroup) { new Section() }
_rootElement = new RootElement ("Unit Converter")
{
new Section() { quantityElem },
new Section("From") { new EntryElement(...), fromUnitElem },
new Section("To") { new EntryElement(...), toUnitElem }
};
_rootVC = new DialogViewController(_rootElement);
_nav = new UINavigationController(_rootVC);
_window.RootViewController = _nav;
_window.MakeKeyAndVisible();
return true;
}
【问题讨论】:
-
看到这个问题 - stackoverflow.com/questions/8302306/…。如果您需要,我在某处有一个更完整的示例。
-
太好了,非常感谢您的帮助,杰森!在发布我的问题之前,我搜索了一个 SO 答案,但我没有看到那个答案。正如该答案中的 cmets 所指出的,这将是 MT.D 的一个很好的补充。
标签: c# xamarin.ios monotouch.dialog