MvvmCross无法在iPhone上为EditingDidBegin创建目标绑定

时间:2013-09-30 19:45:22

标签: mvvmcross

我有一个绑定到EditingDidBegin的应用程序。它在iPhone模拟器(iOS 7)上运行良好,但在实际的iPhone上运行时,我收到以下警告信息:

MvxBind:警告:1.29无法为EditingDidBegin创建目标绑定

控件的绑定代码是:

var set = this.CreateBindingSet<InventoryBalanceView, InventoryBalanceViewModel>();
set.Bind(StoreroomLabel).To(vm => vm.StoreRoomCaption);
set.Bind(StoreroomTextField).To(vm => vm.StoreRoom);
set.Bind(ItemNumberLabel).To(vm => vm.ItemNumberCaption);
set.Bind(ItemNumberTextField).To(vm => vm.ItemNumber);
set.Bind(BinNumberLabel).To(vm => vm.BinNumberCaption);
set.Bind(BinNumberTextField).To(vm => vm.BinNumber);
set.Bind(QuantityLabel).To(vm => vm.QuantityCaption);
set.Bind(QuantityTextField).To(vm => vm.Quantity);
set.Bind(SubmitButton).To(vm => vm.SetFocusCommand);
set.Bind(DeleteButton).To(vm => vm.DeleteCommand);
      set.Bind(NavigationItem.RightBarButtonItem).To(vm => vm.ScanStoreRoomCommand);
set.Bind(DeleteButton).For(b => b.Hidden).To(vm => vm.IsDeleteButtonHidden);

set.Bind(SubmitButton).For("Title").To(vm => vm.SubmitButtonTitle);
set.Bind(DeleteButton).For("Title").To(vm => vm.DeleteButtonTitle);

set.Bind(StoreroomTextField).For("EditingDidBegin").To(vm =>  vm.SetFocusCommand).CommandParameter("StoreRoom");
set.Bind(ItemNumberTextField).For("EditingDidBegin").To(vm => vm.SetFocusCommand).CommandParameter("ItemNumber");
set.Bind(BinNumberTextField).For("EditingDidBegin").To(vm => vm.SetFocusCommand).CommandParameter("BinNumber");
set.Bind(QuantityTextField).For("EditingDidBegin").To(vm => vm.SetFocusCommand).CommandParameter("Quantity");

set.Apply();

我确实将项目设置更改为“链接所有程序集”,但这似乎没有对此问题产生任何影响。

知道我的代码有什么问题,或者如何解决问题?

感谢您的帮助!

1 个答案:

答案 0 :(得分:7)

这种类型的消息 - 加上'它在模拟器中工作'的证据 - 几乎总是意味着链接器已经删除了符号。

不是“将项目设置更改为链接所有程序集”,而是可以向“LinkerPleaseIgnore.cs”(或其他文件)添加一行,这些行会欺骗链接到包括事件。

e.g。包含像https://github.com/slodge/NPlus1DaysOfMvvmCross/blob/master/N-38-Maps/Mappit.Touch/LinkerPleaseInclude.cs这样的文件,其方法如下:

    public void Include(UITextField textField)
    {
        textField.Text = textField.Text + "";
        textField.EditingChanged += (sender, args) => { textField.Text = ""; };
        textField.EditingDidBegin += (sender, args) => { textField.Text = ""; };
        textField.EditingDidBegin -= (sender, args) => { textField.Text = ""; };
    }

这将希望欺骗链接器包含textField.EditingDidBegin符号