【问题标题】:Monotouch Dialog Cannot get out of ILIST because Backbutton is Missing,Monotouch 对话框无法退出 ILIST,因为缺少后退按钮,
【发布时间】:2010-10-14 19:04:16
【问题描述】:

Fahrzeug 级

    {
        [Entry ("Typ")]
        public string typ;
        [Entry ("Name")]
        public string name;
        [RadioSelection("ListOfString")]
        public int selected=0;
        public IList<string> ListOfString;


    }
    public override void ViewWillAppear (bool animated)
    {
        base.ViewWillAppear (animated);
        Fahrzeug x = new Fahrzeug();
        x.typ="Neuwagen";
        x.name="BMW X3";
        x.ListOfString=new List<string>();
        x.ListOfString.Add("asdf");
        x.ListOfString.Add("bsdf");
    var bc= new BindingContext(null,x,"asdf");
        var dv = new MonoTouch.Dialog.DialogViewController(bc.Root,true);
        dv.WantsFullScreenLayout=false;
        dv.View.BackgroundColor=UIColor.DarkGray;


    this.startview.AddSubview(dv.View);

你好, 我有上面的代码。 startview 不是全屏的,上面有个导航栏, 正常的 dv 也超出了导航栏, 但是当我单击 ILISt 来更改值时,ILIST 是全屏的,所以我无法返回,......重要的是,实际是一个 UIView,我想要这个在一个 uiview 中,......我想使用反射,因为这样我可以直接序列化数据 有什么想法吗?

【问题讨论】:

    标签: iphone xamarin.ios monotouch.dialog


    【解决方案1】:

    我遇到了同样的问题,后退按钮没有显示。在查看 DialogViewController.cs 后,我看到构造函数可以采用第二个参数“推送”。 如果设置为true,则返回按钮设置为可见。

    【讨论】:

      【解决方案2】:

      后退按钮来自 UINavigationController。您确实需要创建一个 UINavigationController 来保存您的 DialogViewController,或者您需要手动自定义您的 DialogViewController。

      在第一种情况下,您可以使用:

      var ui = new UINavigationController (dv);
      

      "ui" 然后包含您的实际视图控制器,将其添加到您的顶级窗口,或者如果您已经有一个视图控制器(例如,来自现有控制器中的某个回调):

      PresentModalViewController (ui, shouldAnimate);
      

      或者,您可以手动自定义您的 DialogViewController,您可以在 TweetStation/UI/Timeline.cs 上的 TweetStation 中查看我是如何做到这一点的,并添加您需要的按钮。

      【讨论】:

      • 我有同样的问题,我有一个 DialogViewController 嵌套在 UINavigationController 中,而 UINavigationController 又托管在 UIPopoverController 中。当我在 DialogViewController 的根目录中创建嵌套根目录时,我没有得到后退按钮?我尝试将pushing 选项设置为下面建议的@Darkwood,但无济于事。此外,嵌套根元素的控制器是UITableViewController,不确定这是否会产生任何影响。
      • 其实我想通了也没关系。我在DialogViewController 上的标题被清除了!
      【解决方案3】:

      我遇到了同样的问题,原因是缺少“标题”,因此没有标题的导航控制器不会显示“后退”按钮。

      解决方案很简单,当我生成根元素时,我忘记了第一个根的标题,如下所示:

      var root = new RootElement("Settings"){ // <-- IMPORTANT! A title must be set here(!)
              new Section("Current server"){
                  new RootElement("Server", new RadioGroup (0)){
                      //...
                  }
              },
      

      我继承的DialogViewController的构造器例如:

      public partial class SettingsViewController : DialogViewController
      {
          public SettingsViewController () :
              base (UITableViewStyle.Grouped, null, true)
          {
              Root = GetRoot();
          }
      

      这就像一个魅力;-)

      顺便说一句:在视图中我会添加一个按钮并重新加载数据:

      public override void ViewWillAppear (bool animated)
      {
              NavigationItem.SetRightBarButtonItem(
                  new UIBarButtonItem("Add Server", UIBarButtonItemStyle.Plain, (sender,args) => {
                  // button was clicked
      
                  NavigationController.PushViewController(new AddServerDialogViewController(), true);
      
              }), true);
      
              //TableView.SetEditing(true, true);
      
              ReloadData();
      
              base.ViewWillAppear(true);
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-31
        • 2012-08-22
        • 2011-07-12
        相关资源
        最近更新 更多