Monotouch.Dialog two tables

2019-06-03 14:10发布

问题:

I'm new to MonoTouch. I need to display 2 tables and button between them in 1 view using monotouch.dialog. It should looks like

---top of screen---
I BoolElement     I
I StringElement   I
I StringElement   I          <--- Yeah,yeah this is iPhone(in my Opinion)
I --empty space-- I
I button          I
I --empty space-- I
I StringElement   I
---End Of screen--

I have searched over an internet - But nothing similar to find. :( The problem is to display last strigElement

回答1:

With MonoTouch.Dialog you can use something like:

    RootElement CreateRoot ()
    {
        var btn = new UIButton ();
        btn.TouchUpInside += delegate {
            Console.WriteLine ("touch'ed");
        };
        // TODO: customize button look to your liking
        // otherwise it will look like a text label
        btn.SetTitle ("button", UIControlState.Normal);
        Section s = new Section ();
        s.HeaderView = btn;
        return new RootElement (String.Empty) {
            new Section () {
                new BooleanElement ("bool", false),
                new StringElement ("s1"),
                new StringElement ("s2"),
                },
            new Section (),
            s,
            new Section () {
                new StringElement ("s3"),
            },
        };      
    }

That will use a Section to add an UIButton inside the HeaderView. The same trick can be used to add any other kind of control.