2012-02-16 80 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