2012-02-16 83 views
1

我无法弄清楚如何正确设计RadioGroup的推送视图控制器导航返回项目。Monotouch Dialog Datepicker和RadioGroup Navigationitem

所以在可选语言的后续屏幕中,后退按钮显示“设置”并且是蓝色。但我想说回来,并改变它的设计哪些机制存在,我已经在其他屏幕上使用。

我建立起来这样的:

var rootSettings = new RootElement ("Settings"); 
      var sectionNotificationSettings = new Section ("Notification settings"); 

      BooleanElement pushEnabled = new BooleanElement("Push notifications", settings.PushEnabled); 
      sectionNotificationSettings.Add(pushEnabled); 

      var sectionCountrySettings = new Section("Country settings"); 
      var rootRadioGroup = new TransparentRootElement ("Language", new RadioGroup("languages", 0)); 

      var sectionRadioElements = new Section(""); 

      foreach(var language in settings.Languages) 
      { 
       RadioElement selectableLanguage = new RadioElement(language.Key, "languages"); 
       sectionRadioElements.Add(selectableLanguage); 
      } 

      rootRadioGroup.Add(sectionRadioElements); 

      sectionCountrySettings.Add(rootRadioGroup); 

      rootSettings.Add (sectionNotificationSettings); 
      rootSettings.Add(sectionCountrySettings); 

在这里,我定义,我想我可以编辑导航项目的TransparentRootElement:的

public class TransparentRootElement : RootElement { 

public TransparentRootElement (string caption) : base (caption) 
{ 

} 

public TransparentRootElement (string caption, Group radioGroup) : base (caption, radioGroup) 
{ 

} 

public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path) 
{  
    base.Selected (dvc, tableView, path, true); 
} 

void HandleMenuButtonTouchUpInside (object sender, EventArgs e) 
{ 
    _dvc.NavigationController.PopViewControllerAnimated(true); 
} 

public override UITableViewCell GetCell (UITableView tv) 
{ 
    var cell = base.GetCell (tv); 
    //cell.BackgroundColor = UIColor.White; 

    return cell; 
} 
} 

我试过很多的编辑方法,但没有工作。我也开始编辑Monotouch对话框中的Elements.cs,但这也没有帮助我很多。

任何有建议的人?

非常感谢!

回答

0

我相信要更改导航的后退按钮,您必须隐藏默认后退按钮,然后分配您自己的。

toPushscreen.NavigationItem.SetHidesBackButton(true, true); 
toPushscreen.NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, myHandler); 
currentScreen.NavigationController.PushViewController(toPushscreen, true); 

希望这有助于:像这样的东西(你推新视图控制器权之前,我相信你的情况,你把语言屏幕之前这将是)!

+0

你好TChadwick, 我不是自己推语言屏幕。这是通过monotouchdialog完成的。我只是添加一个新的RootElement与Radiogroup和部分,如果我点击组rootelement自动推动。内部MonTouchDialog使用了我在elements.cs中找到的推送机制,但是我不想在那里改变它。 – 2012-02-20 09:35:02

+0

感谢您的澄清,我还没有任何使用monotouch对话框的经验,但是,如果您使用的是最后一次单击更新附带的monotouch对话框的版本,我会检查并查看,如果是,则可以尝试在github上切换到最新版本,或者如果您使用的是github版本,则可以切换到上次构建monodouch时随附的内置版本。只有几个想法... – TChadwick 2012-03-13 15:07:33