我在Xamarin Studio中运行了针对Mono 2.10.11的iOS预约应用程序。
约会详细信息屏幕允许根据结果对约会进行评级。允许评级的按钮基于基于业务逻辑的布尔集显示。绑定按钮触发评级屏幕的打开。它在iOS 6.1的Mobile and Debugger和iOS 7模拟器上正常工作。它不适用于iOS 7设备。
AppointView.cs包含ViewDidLoad函数,它按如下方式设置按钮: -
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'}}"}
});
在通过创建约会视图运行程序时,我收到以下警告: -
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
AppointmentViewModel包含事件: -
public ICommand GoToSessionRateView
{
get
{
return new MvxRelayCommand(() => RequestNavigate<SessionRateViewModel>(new { appointmentId = _appointmentId }));
}
}
不确定导致事件停止工作的原因。任何指针都会受到赞赏。
答案 0 :(得分:4)
通常,在设备上不起作用的东西是由Xamarin“链接器”引起的,并且可以使用许多选项来解决 - 请参阅Trouble with xamarin.ios/monotouch , mvvmcross and linking
发生这种情况时,我首选的选项是使用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
更改为Converter
可能有所帮助。