我正在尝试使用MonoTouch.Dialog创建一个非常基本的RadioGroup。在选项列表中选择一个项目并返回主视图后,RadioGroup仍然显示已选择默认值。但是,当我选择另一个项目时,仍会选中我选择的上一个值。我在网上查看了几个例子,但似乎没有一个例子做任何特别的事情来使主视图反映新选择的值。我做错了什么/错过了什么?
以下是我的代码的简化版本:
using System;
using MonoTouch.Dialog;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace TestApp
{
public class MainSettings : DialogViewController
{
public MainSettings (UIViewController parent) : base (UITableViewStyle.Grouped, null)
{
Root = new RootElement ("Settings")
{
new Section("Cellular Network")
{
new RootElement("Refresh Data", new RadioGroup(2))
{
new Section()
{
new RadioElement("Every 5 Minutes"),
new RadioElement("Every 15 Minutes"),
new RadioElement("Every 30 Minutes"),
new RadioElement("Hourly"),
new RadioElement("Manually")
}
}
}
};
}
public override void ViewWillAppear (bool animated)
{
NavigationItem.RightBarButtonItem = new UIBarButtonItem ("Close", UIBarButtonItemStyle.Plain, delegate
{
DismissModalViewControllerAnimated (true);
}
);
}
}
}
谢谢, 好色
答案 0 :(得分:1)
这比我原先想象的更明显。我没有打电话给 base.ViewWillAppear !