gpt4 book ai didi

xamarin.ios - 如何动态添加新的 Monotouch 对话框 View ?

转载 作者:行者123 更新时间:2023-12-04 05:27:30 25 4
gpt4 key购买 nike

在 Monotouch Dialog 中创建 View 时,一种可能的方法是创建 .cs保存 View 信息的文件,如下所示:

[Caption("Create user")]
[Alignment(UITextAlignment.Center)]
public RegistrationSchema CreateAccount;

但是说我需要动态添加按钮,如下所示:
//This is what I'd like to do, but there doesn't seem to be any support for this
_newUserSection = new Section("Create user) {
new RegistrationSchema()
};

有什么想法吗?

编辑 我的 RegistrationSchema.cs文件
public class RegistrationSchema
{
[Section("Fill out the form")]

[Caption("E-mail")]
[Entry(KeyboardType=UIKeyboardType.EmailAddress)]
public string Email;

//more stuff here
}

最佳答案

// Create a new section
var section = new Section("A section");
// Create a new element
var elem = new StringElement("String Element")
// Add element to section
section.Add(elem);
// Add section to root.
Root.Add(section);
// Refresh
Root.ReloadData();

全部记录在这里 https://github.com/migueldeicaza/MonoTouch.Dialog在 Xamarin 教程中,就像在那里 http://blog.xamarin.com/2012/02/10/easily-create-ios-user-interfaces-with-monotouch-dialog/

要推送新 Controller ,请使用 RootElement:
var newRoot = RootElement("Another root", new ThisWillBePushedController());
root.Add(newRoot);

点击 newRoot 将插入 ThisWillBePushedController()。
请注意,如果您使用 UINavigationController,您将必须覆盖 MonoTouch.DialogViewController 并调用基本 c'tor,并为最后一个参数“pushing”传递 TRUE。

关于xamarin.ios - 如何动态添加新的 Monotouch 对话框 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13027327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com