Monotouch.Dialog:在 RadioElement 表中选择后,如何更新依赖表? [英] Monotouch.Dialog: After selection in a RadioElement table, how to update a dependent table?

查看:21
本文介绍了Monotouch.Dialog:在 RadioElement 表中选择后,如何更新依赖表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Monotouch.Dialog 开发一个单位转换器,我有一个如下所示的主窗口:

I am developing a Unit Converter using Monotouch.Dialog, and I have a main window that looks like this:

当我点击 Quantity 元素时,选择一个新的 Quantity 并返回主窗口,我想使用与所选数量关联的单位表更新 Unit 元素.

When I tap the Quantity element, select a new Quantity and return to the main window, I want to update the Unit elements with a table of units associated with the selected quantity.

我最初的想法是在完成数量选择后调用的事件处理程序中更新单位.但是,当我从数量选择返回时,我无法在 MT.D API 中找到触发的事件.有没有我可以采取行动的事件,或者我可以通过其他方式进行单元更新吗?

My initial thought was to make an update of the units in an event handler that would be invoked after completed quantity selection. However, I have not been able to find an event in the MT.D API that is fired when I return from the quantity selection. Is there such an event that I could act upon, or is there another way I can do the unit updating?

示意性地,我的 AppDelegate.FinishedLaunching 方法现在看起来像这样:

Schematically, my AppDelegate.FinishedLaunching method looks like this right now:

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;
}

推荐答案

正如 Jason 在上面的评论中指出的,这个问题之前已经在 SO 上解决了,这里.

As pointed out by Jason in a comment above this problem had been addressed previously on SO, here.

解决方案是扩展RadioElement 类,其中继承类包含一个OnSelected 事件,并且RadioElement.Selected 方法被覆盖调用 OnSelected 事件处理程序的方法.

The solution is to extend the RadioElement class, where the inheriting class contains an OnSelected event and the RadioElement.Selected method is overridden with a method that invokes the OnSelected event handler(s).

这篇关于Monotouch.Dialog:在 RadioElement 表中选择后,如何更新依赖表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆