Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MvvmCross Failed to create target binding for EditingDidBegin on iPhone

Tags:

mvvmcross

I have an application which binds to EditingDidBegin. It works fine on the iPhone Simulator (iOS 7) but when running on an actual iPhone I get the following warning message:

MvxBind:Warning: 1.29 Failed to create target binding for to EditingDidBegin

The binding code for the controls is:

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();

I did change the project settings to Link All Assemblies, but that doesn't seem to have had any impact on the issue.

Any idea what's wrong with my code, or how to troubleshoot the issue?

Thanks for your help!

like image 271
Mark Entner Avatar asked Mar 22 '23 05:03

Mark Entner


1 Answers

This type of message - coupled with the 'it works in the simulator' evidence - almost always means that the linker has removed the symbol.

Instead of "change the project settings to Link All Assemblies", can you add a line to "LinkerPleaseIgnore.cs" (or to some other file) which tricks the linked into including the event.

e.g. include a file like https://github.com/slodge/NPlus1DaysOfMvvmCross/blob/master/N-38-Maps/Mappit.Touch/LinkerPleaseInclude.cs with a method like:

    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 = ""; };
    }

This will hopefully trick the linker into including the textField.EditingDidBegin symbol

like image 61
Stuart Avatar answered May 02 '23 03:05

Stuart