1

I have an iOS appointment app running against Mono 2.10.11 in Xamarin Studio.

The appointment detail screen allows appointments to be rated based on their outcome. A button to allow the rating is displayed based on a boolean set based on business logic. The bound button triggers the opening of the rating screen. It works normally in iOS 6.1 on Mobile and Debugger and on iOS 7 simulator. It does not work on an iOS 7 device.

The AppointView.cs contains the function ViewDidLoad which sets up the button as follows: -

AppointmentViewTable.Source = _source;

this.AddBindings (new Dictionary<object, string>
{
    { _source, "{'ItemsSource':{'Path':'AppointmentDetails'}, 'HeaderTitle':{'Path':'Appointment.AppointmentDate','converter':'DateTime'}}" },
    { btnRateSession, "{'Hidden':{'Path':'Appointment.RateAvailable','converter':'InvertedVisibility'}, 'Title':{'Path':'TextSource','Converter':'Language','ConverterParameter':'btnRateSession'}, 'TouchDown':{'Path':'GoToSessionRateView'}}"}
});

On running the program through creation of the appointment view I get the following warning: -

2013-10-18 16:58:55.012 M2FitiOS[3773:a0b] MvxBind: Error:  14.12 Problem seen during binding execution for from Appointment.RateAvailable to Hidden - problem InvalidCastException: Null object can not be converted to a value type.
at System.Convert.ToType (System.Object value, System.Type conversionType, IFormatProvider provider, Boolean try_target_to_type) [0x00017] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Convert.cs:2553 
at System.Convert.ChangeType (System.Object value, System.Type conversionType, IFormatProvider provider) [0x00017] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Convert.cs:2204 
at Cirrious.MvvmCross.Binding.ExtensionMethods.MvxTypeExtensions.MakeSafeValue (System.Type propertyType, System.Object value) [0x00000] in <filename unknown>:0 
at Cirrious.MvvmCross.Binding.Bindings.Target.MvxPropertyInfoTargetBinding.SetValue (System.Object value) [0x00000] in <filename unknown>:0 
at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource (Boolean isAvailable, System.Object value) [0x00000] in <filename unknown>:0

The AppointmentViewModel contains the event :-

public ICommand GoToSessionRateView
{
    get
        {
            return new MvxRelayCommand(() => RequestNavigate<SessionRateViewModel>(new { appointmentId = _appointmentId }));
        }
    }

Not sure what has caused the event to stop working. Any pointers would be appreciated.

4

1 回答 1

4

通常情况下无法在设备上运行的原因是 Xamarin“链接器”,可以使用多种选项来解决 - 请参阅xamarin.ios/monotouch 、 mvvmcross 和链接的问题

发生这种情况时,我的首选选项是使用LinkerPleaseInclude.cs文件 - 例如https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ApiExamples/ApiExamples.Touch/LinkerPleaseInclude.cs

如果这是您的问题,那么您需要确保 LinkerPleaseInclude 包含一个TouchDown参考 - 尽管如果您实际上将绑定更改为,您可能会更开心TouchUpInside


同时,您的跟踪显示错误Appointment.RateAvailable to Hidden-我很困惑为什么在 ios7 上应该有所不同。我怀疑在这个旧版本的 MvvmCross 中解决它的最简单方法可能是升级......尽管简单地将其更改converter为 a Converter也可能会有所帮助。

于 2013-10-18T17:59:18.620 回答