Monotouch对话框无法退出ILIST因为缺少返回按钮。

3

车辆类

    {
        [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中使用它,..并且我想使用反射,因为这样我可以直接序列化数据 有什么想法吗?

3个回答

9

我曾经遇到同样的问题,后退按钮没有显示。在查看DialogViewController.cs文件后,我发现构造函数可以带有第二个参数"pushing"。 如果将其设置为true,则后退按钮将被显示。


3

“返回按钮”来自UINavigationController。您需要创建一个UINavigationController来容纳您的DialogViewController,或者手动定制您的DialogViewController。

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

var ui = new UINavigationController (dv);

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

PresentModalViewController (ui, shouldAnimate);

另外,您可以手动自定义DialogViewController,您可以在TweetStation / UI / Timeline.cs上查看我如何执行此操作,并添加所需的按钮。


我有同样的问题,我在UINavigationController中嵌套了一个DialogViewController,而这个UINavigationController又被放置在一个UIPopoverController中。当我在我的DialogViewController的根目录中创建一个嵌套根时,我没有得到返回按钮?我尝试设置pushing选项,如@Darkwood在下面建议的那样,但无济于事。此外,嵌套根元素的控制器是一个UITableViewController,不确定是否会产生任何影响。 - James
1
实际上,没事了,我已经解决了。我的 DialogViewController 上的标题被清除了! - James

1
我经历了同样的问题,原因是"Title"缺失,所以没有标题的导航控制器不会显示"返回"按钮。
解决方案很简单,当我生成根元素时,我忘记为第一个根元素添加标题了,就像这样:
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();
    }

This works like a charm ;-)
顺便说一句,在viewwillappear中我添加了一个按钮并重新加载数据:
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);
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接