2014-03-25 50 views
2

我想了解一個Xamarin.iOS項目的ReactiveUI,並且我堅持什麼應該是一個簡單的任務。我無法像在我的同伴Xamarin.Android項目中那樣將按鈕點擊綁定到ReactiveCommand。下面是Android的代碼工作正常:如何綁定iOS中的ReactiveUI中的按鈕點擊命令

this.BindCommand (ViewModel, x => x.ClickMe, view => view._button);

這是iOS中使用相同的模式:

this.BindCommand (ViewModel, x => x.ClickMe, view => view.GetForecastButton);

然而,在iOS中,我得到以下警告:

「找不到MonoTouch.UIKit.UIButton的命令活頁夾」

有沒有人知道我是doi恩錯了嗎?令人驚訝的是,我查閱了數十個ReactiveUI iOS示例,並且我還沒有發現在應用程序中甚至只有一個按鈕。他們都做類似於從綁定屬性中顯示文本或從ViewModel中的集合中顯示UITableView。我確信有一個更完整的iOS例子,如果有人知道一個請在你的答案中包括。非常感謝。

回答

2

你正在做的一切都正確,但我相信你被一個影響ReactiveUI的Xamarin.iOS錯誤所淹沒,其中Type.GetType不會加載程序集。粘貼到您的AppDelegate:

https://github.com/paulcbetts/starter-mobile/blob/master/Starter-iOS/AppDelegate.cs#L35

 // NB: GrossHackAlertTiem™: 
     // 
     // Monotouch appears to not load assemblies when you request them 
     // via Type.GetType, unlike every other platform (even 
     // Xamarin.Android). So, we've got to manually do what RxUI and 
     // Akavache would normally do for us 
     var r = RxApp.MutableResolver; 
     (new ReactiveUI.Cocoa.Registrations()).Register((f,t) => r.Register(f, t)); 
     (new ReactiveUI.Mobile.Registrations()).Register((f,t) => r.Register(f, t)); 
+0

感謝保羅。這工作得很好。 – Grahambo