我是Xamarin和MVVMCross的新手。所以我創建了2個視圖。登錄和註冊。我不得不轉到註冊視圖上的登錄按鈕,我通過這段代碼在登錄的視圖模型去那裏:第二個視圖對象的名稱分配崩潰
// method when user tap register button
public IMvxCommand NavigateRegister
{
get { return new MvxCommand(() => ShowViewModel<RegisterViewModel>()); }
}
它工作正常的註冊頁面打開好。但是,一旦我在Register視圖(textEdit)上爲單個對象指定Name,當點擊Register按鈕時,應用程序會崩潰。
下面是錯誤信息:
Xamarin.iOS:收到未處理的ObjectiveC異常: NSUnknownKeyException [ 的setValue:forUndefinedKey:]:此類不是密鑰值 編碼兼容的關鍵regNameEdit。
而且觀點也被分配到其類「的createAccount」。但是我注意到,在「public partial class CreateAccount : MvxViewController
」這一行中,類聲明已經「部分」變暗了。這是這個類和第一個唯一明顯的區別。
using MvvmCross.Binding.BindingContext;
using MvvmCross.iOS.Views;
namespace MyApp.iOS.Views
{
public partial class CreateAccount : MvxViewController
{
public CreateAccount() : base("CreateAccount", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
Title = "Register";
var set = this.CreateBindingSet<CreateAccount, Core.ViewModels.CreateAccountModel>();
set.Bind(regNameEdit).To(vm => vm.NameStr);
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
}
}
的綁定(regNameEdit)也是一個錯誤(沒有檢測到文本編輯靜止)
嗨,謝謝你的回答。我其實已經這樣做了,但仍然發生了事故。如果您想查看,我在問題中添加了更多細節。 – GeneCode
@GeneCode在答案中增加了更多信息... – apineda
我想我缺少一些基本的東西。我沒有意識到這個項目有一個故事板和一個視圖控制器。現在我在xib中設計所有東西。不知道viewcontroller如何鏈接到firstview.xib。 – GeneCode