UILongPressGestureRecognizer のような iOS ジェスチャを MvvmCross の ICommand または MvxCommand にバインドする方法を探しています。
PS:ここで例を見つけましたが、その方法がわかりません。
UILongPressGestureRecognizer のような iOS ジェスチャを MvvmCross の ICommand または MvxCommand にバインドする方法を探しています。
PS:ここで例を見つけましたが、その方法がわかりません。
あなたが見つけた例と現在のMVVMクロスソースから、私は次のことをしました
public static class MvxBehaviourExtensions
{
public static MvxLongPressGestureRecognizerBehaviour LongPress(this UIView view)
{
var toReturn = new MvxLongPressGestureRecognizerBehaviour(view);
return toReturn;
}
}
と
public class MvxLongPressGestureRecognizerBehaviour
: MvxGestureRecognizerBehavior<UILongPressGestureRecognizer>
{
protected override void HandleGesture(UILongPressGestureRecognizer gesture)
{
// Long press recognizer fires continuously. This will ensure we fire
// the command only once. Fire as soon as gesture is recognized as
// a long press.
if (gesture.State == UIGestureRecognizerState.Began)
{
FireCommand();
}
}
public MvxLongPressGestureRecognizerBehaviour(UIView target)
{
var lp = new UILongPressGestureRecognizer(HandleGesture);
AddGestureRecognizer(target, lp);
}
}
そして縛る
set.Bind(this.LongPress()).For(lp => lp.Command).To(c => c.DoTheStuffCommand);