我一直在关注 monotouch.dialog 任务示例应用程序 (http://docs.xamarin.com/ios/Guides/User_Interface/MonoTouch.Dialog/Elements_API_Walkthrough) 中的代码。
我似乎无法解决的问题是,当用户单击 + 按钮时,表格中会添加一个新行。用户触摸它并导航到另一个屏幕,他们可以在其中输入信息。现在,当他们导航回根视图时,我希望更新 rootElements 列表,以便使用输入的名称而不是默认名称“连接”
我将如何根据输入的内容更新每个 RootElements 的文本?
我希望一切都有意义!
-- 下面的代码。
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
RootElement _rootElement = new RootElement ("To Do List"){ new Section()};
DialogViewController _rootVC = new DialogViewController (_rootElement);
// This adds an 'add' button to the root view controller, and handles by delegate,the push to a screen where you can add a new vCenter connection profile.
UIBarButtonItem _addButton = new UIBarButtonItem (UIBarButtonSystemItem.Add);
_rootVC.NavigationItem.RightBarButtonItem = _addButton;
_addButton.Clicked += (sender, e) => {
var connectionProfile = new connectionProfile{};
// See, on the line below, I add a default RootElement with the text New Connection.
var connectionProfileElements = new RootElement ("New Connection") {
new Section () {
// When they enter the name on the next line of code, I want to use this to update the New Connection text on the root screen.
new EntryElement ("Name", "Enter Connection Name", connectionProfile._connectionName),
new EntryElement ("VC Address", "Enter VC Address", connectionProfile._address),
new EntryElement ("VC Port", "Enter VC Port", connectionProfile._port),
new EntryElement ("Username", "Enter Username", connectionProfile._userID),
new EntryElement ("Password", "Enter Password", connectionProfile._password,true)}
};
_rootElement [0].Add (connectionProfileElements);
};
UINavigationController _nav = new UINavigationController (_rootVC);
window.RootViewController = _nav;
window.MakeKeyAndVisible ();
return true;
}
}
和 :
public class connectionProfile
{
public connectionProfile ()
{
}
public string _connectionName { get; set; }
public string _address { get; set; }
public string _port { get; set; }
public string _userID {get; set; }
public string _password { get; set; }
}