【问题标题】:Can you place two edit fields side-by-side?您可以并排放置两个编辑字段吗?
【发布时间】:2012-03-05 02:03:53
【问题描述】:

在我见过的所有示例中,每行只有一个元素。我想将 2 个或更多编辑框并排放置以节省垂直空间。有没有人遇到过示例显示这是如何完成的?

【问题讨论】:

    标签: c# ios xamarin.ios monotouch.dialog


    【解决方案1】:

    这在大多数应用程序中并不常见(由于屏幕尺寸有限),但您应该能够使用 UIViewElement 执行类似的操作。例如

    定义您自己的UIView 类型(例如MyView),其中包含您想要的两个(或更多)UI 元素(例如两个UITextView)。

    // incomplete example
    class MyView : UIView {
    
       public UIView (string first, string second)
       {
           tv1 = new UITextView (new RectangleF (...)) { Text = first; }
           tv2 = new UITextView (new RectangleF (...)) { Text = second; }
       }
    
       // ...
    }
    

    接下来创建UIViewElement 并将它们添加到您的DialogViewController

    new UIViewElement ("caption", new MyView ("a", "b"), false);
    

    【讨论】:

    • 感谢您的建议。我决定为每个条目元素使用单独的行,但我确信以后可以使用这种技术。感谢您的回复。
    猜你喜欢
    • 2016-12-12
    • 2023-04-02
    • 2021-09-18
    • 2011-02-20
    • 1970-01-01
    • 2017-02-02
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    相关资源
    最近更新 更多