2013-10-18 49 views
1

我有一個iOS預約應用程序運行Xamarin Studio中的Mono 2.10.11。MVVMCross界限按鈕事件不會觸發按

約會詳細信息屏幕允許約會根據他們的結果進行評分。基於業務邏輯的布爾集合顯示允許評級的按鈕。綁定的按鈕觸發打開評級屏幕。它可以在iOS 6.1的Mobile和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

有些東西是空的。修復。另外我會推薦使用最新版本的MvvmCross。 – Cheesebaron

回答

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,這可能會有所幫助。

+0

感謝您的建議。建立並開始升級。 – Gaius